Skip to content Skip to sidebar Skip to footer

Textarea Value Not Showing Any New Lines Breaks

Possible Duplicate: The .val() of a textarea doesn't take new lines into account I have a text area when i type a message in the text area with newlines and get the value back f

Solution 1:

Make sure you are intepreting your line breaks \r\n as <br /> tags.

text.replace(/\n\r?/g, '<br />'); 

If you're using PHP there is the nl2br() function. Or any other language, the above regex should work.

Solution 2:

You have to convert new lines to html tags with nl2br() function before outputting.

Solution 3:

if you're using PHP to process the input from your textarea, you can use the nl2br() function to convert newline characters to <br/>. You can also accomplish this in javascript using string.replace(/\n/g, '<br/>');.

Post a Comment for "Textarea Value Not Showing Any New Lines Breaks"