javascript - Disable the ability to post HTML content to a Textarea -


i'm facing weird problem html code. people started posting html content such html forms, input boxes, check boxes via textarea , messed website's content. need disable ability post html content via textareas , allow text. example: if type html <input> tag, that'll delivered text , not html.

however, need enable ability post content <a> tags since i'm allowing ability post links, etc. should given ability post <img> tags has specific class (class name 'emoji-class'), since i'm giving ability post emojis.

conditions:

  • allow text contain <a href> tags
  • allow text contain <img> that contain class named 'emoji-class'. other <img> tag not passed html content via text area

i receive content via javascript:

https://jsfiddle.net/wv4s511e/11/

how can add these conditions textarea/javascript such every other html content received text content aforementioned html tags received html content?

edit:

i'm coding on asp.net

disabling ability post html bad idea, better way encode html tags they're being shown on webpage.

this way, dom won't recognise html tags , won't mess code, still shows on webpage itself.

more information: http://www.w3schools.com/asp/met_htmlencode.asp


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -