<p>You can use the <a href="http://twig.sensiolabs.org/doc/filters/striptags.html" rel="nofollow"><code>striptags</code></a> filter to remove all HTML tags from your string. With the <a href="http://twig.sensiolabs.org/doc/filters/trim.html" rel="nofollow"><code>trim</code></a> filter you can strip all whitespace from the beginning and the end of it:</p>

<pre><code>{% if entry.poorText|striptags|trim %}
    {{ entry.poorText }}
{% else %}
    Here could be a nicely formatted text! 
{% endif %}
</code></pre>

CC BY-SA 3.0
2014-12-18T18:06:15.813Z
in twig, an empty string evaluates to `false`, so you could just test `{% if entry.poorText|striptags|trim %}`
Marion Newlevant
CC BY-SA 3.0
2014-12-18T18:12:53.577Z
Right. Thx @Marion.
carlcs
CC BY-SA 3.0
2014-12-18T16:34:51.873Z
2014-12-18T18:13:15.963Z
2014-12-18T18:13:15.963Z
carlcs
<p>I have a rich text field which contains:</p>

<pre><code>&lt;p&gt;&lt;br&gt;&lt;/p&gt;
</code></pre>

<p>This is what is left when you delete all content of a redactor field.
This can't be deleted without the HTML view of Redactor.</p>

<p>Is it possible to write a conditional that checks for an empty field ignoring HTML markup?</p>

<pre><code>{% if entry.poorText is not empty %}
   {{ entry.poorText }}
{% endif %}
</code></pre>

<p>Does not work in this case.</p>

<conditional><redactor><richtext>
Test for empty RichText field
# Test for empty RichText field

(Asked by: username_0 on 2014-12-18)

I have a rich text field which contains:


This is what is left when you delete all content of a redactor field.
This can't be deleted without the HTML view of Redactor.
Is it possible to write a conditional that checks for an empty field ignoring HTML markup?
{% if entry.poorText is not empty %}
   {{ entry.poorText }}
{% endif %}

Does not work in this case.

**Tags:** conditional, redactor, richtext

---

## 1 answers

### Answer by username_1 on 2014-12-18. Score: 6 | Accepted answer

You can use the striptags filter to remove all HTML tags from your string. With the trim filter you can strip all whitespace from the beginning and the end of it:
{% if entry.poorText|striptags|trim %}
    {{ entry.poorText }}
{% else %}
    Here could be a nicely formatted text! 
{% endif %}

> **Comments:**
> **username_2**: in twig, an empty string evaluates to `false`, so you could just test `{% if entry.poorText|striptags|trim %}`  
> **username_1**: Right. Thx @Marion.  

---

