# Prevent HTML use in textarea field?

**URL:** <https://forum.getkirby.com/t/prevent-html-use-in-textarea-field/9896>\
**Category:** Questions\
**Tags:** v2\
**Created:** [March 6, 2018, 3:04pm UTC](https://forum.getkirby.com/t/prevent-html-use-in-textarea-field/9896 "2018-03-06T15:04:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![julieng](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/julieng/32/6770_2.png) [@julieng](https://forum.getkirby.com/u/julieng)\
**Post date:** [March 6, 2018, 3:04pm UTC](https://forum.getkirby.com/t/prevent-html-use-in-textarea-field/9896/1 "2018-03-06T15:04:17Z")

</div>

Hi there,

Long time without a question, but today I wonder if there is a way to prevent editors to use HTML in textarea (and text) fields but keep available markdown?

I used to write in my template:

```auto
<?php echo kirbytext( html::decode( $page->text() ) ); ?>

```

I also could do a page or field method, but is it the good way?  
Any help will be apreciated!

Cheers,  
j.

---

<div class="post-metadata">

**Author:** ![dreadnip](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/dreadnip/32/4218_2.png) [@dreadnip](https://forum.getkirby.com/u/dreadnip)\
**Post date:** [March 6, 2018, 3:13pm UTC](https://forum.getkirby.com/t/prevent-html-use-in-textarea-field/9896/2 "2018-03-06T15:13:48Z")

</div>

You could use [-\>markdown()](https://getkirby.com/docs/cheatsheet/field-methods/markdown) instead of -\>kirbytext()

```
<?= $page->text()->markdown() ?>

```

Edit: Nevermind, that still parses HTML. You could teach your editors to escape the HTML but I guess that’s not really what you’re trying to do here. You want to force them to not use it right?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 6, 2018, 3:20pm UTC](https://forum.getkirby.com/t/prevent-html-use-in-textarea-field/9896/3 "2018-03-06T15:20:33Z")

</div>

> [@dreadnip](#):
>
> \<?= $page-\>text()-\>markdown() ?\>

That doesn’t remove HTML tags…

Maybe use a Kirbytext filter, then you don’t have to use it all the time. Wouldn’t work with non-Kirbytext fields…

Anyway, there is no way to prevent editors to enter HTML tags apart from telling them no to, for example in a help text. But if you can’t trust them, you have to get rid of these tags afterwards. Just like you have to escape stuff anyway when outputting your content.

---

<div class="post-metadata">

**Author:** ![julieng](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/julieng/32/6770_2.png) [@julieng](https://forum.getkirby.com/u/julieng)\
**Post date:** [March 6, 2018, 3:45pm UTC](https://forum.getkirby.com/t/prevent-html-use-in-textarea-field/9896/4 "2018-03-06T15:45:07Z")

</div>

> [@dreadnip](#):
>
> You want to force them to not use it right?

That is exactly the purpose 🙂

> [@texnixe](#):
>
> Anyway, there is no way to prevent editors to enter HTML tags apart from telling them no to, for example in a help text. But if you can’t trust them, you have to get rid of these tags afterwards. Just like you have to escape stuff anyway when outputting your content.

So, maybe I will keep it the way I used to. Just make it nicer by using a field method…

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:29pm UTC](https://forum.getkirby.com/t/prevent-html-use-in-textarea-field/9896/5 "2025-02-06T17:29:53Z")

</div>


