Filling a text field with special characters

I fill in the text box with the previous user input. This is retrieved from the database and installed as the contents of the textarea server.

We seem to have a typo problem and a combination of special characters. if the user initially enters when I try to fill my text area so that it simply displays a small square, as the encoded value of the character interprets it.

Creating an HTML file with the following demonstrates my problem.

<textarea name"mytextarea">some text &#5 some more text </textarea

it's a typo, the user intended to enter # 5 and # 6, so the fix for this is to simply ensure that the user places the ampersand in that I have space on either side of it before I show it in the text box. This is just a special problem, the opposite of what I use for viewing.

I am curious if there is a way for the text area to display characters as the user typed it and saved it by submitting the form. To save overhead the need for parsing or html to encode text before placing it in a text field.

Thanks, Muchly

+3
source share
2 answers

textarea HTML:

& => &amp;
> => &gt;
< => &lt;

,  &amp;#5. .

, . PHP htmlspecialchars()

+8

&amp;

+2

Source: https://habr.com/ru/post/1771802/


All Articles