Get the exact contents of a textarea using javascript -


i have text area looks this:

<textarea id="txtbody" name="txtbody">q2312312312<strong>313213213</strong>21231321231231 &lt; &amp;lt;</textarea> 

when in javascript:

var t = document.getelementbyid('txtbody').value; 

i back:

<p>q2312312312<strong>313213213</strong>21231321231231 < &lt;</p> 

seems should give me exact characters are... missing something? there way exact characters out of text area?

am missing something?

& html "start entity".

when put text html document (between start , end tags textarea), failing represent text html.

as result, browser performs error recovery , treats <strong> "a less character, word strong, greater character" (because tags not allowed inside textarea element, treats &lt; "a less character" because there isn't machine detectable error here.

is there way exact characters out of text area?

you need write html correctly in first place.

<textarea id="txtbody" name="txtbody">q2312312312&lt;strong&gt;313213213&lt;/strong&gt;21231321231231 &amp;lt; &amp;amp;lt;</textarea> 

Comments