user3693234
user3693234

Reputation: 31

HTML Tags Not Displaying Properly Inside Textarea

I have problems with my text area field. When I select the value from database to my textarea field, the browser can't understand the HTML tags (ex: </br>).

This is my field :

<textarea id="id_get_post_description2"  maxlength="9999" name="description_post"  style="resize:none; font-size: 12pt; width:100%;  height:90%; border:1px solid #0099FF;" type="text"></textarea>

Upvotes: 0

Views: 112

Answers (3)

user3693234
user3693234

Reputation: 31

Thanks for the help! You give me idea to replace, and i'm fixed it with one string :)

description_post = description_post.replace(/<br>/g, "\n");

Upvotes: 0

user3968801
user3968801

Reputation:

You have to use escape characters: Take a look at this for further information: http://www.w3.org/International/questions/qa-escapes#answer

Upvotes: 1

Troels Larsen
Troels Larsen

Reputation: 4631

You need to escape the html reserved characters: http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php

So instead of <, you should use &lt;. This should be replaced either by your database or when generating the HTML.

Upvotes: 0

Related Questions