I have textarea and i want, when i post the form if t开发者_运维技巧here are any new lines in the text area to get them and output the text with them, like the wysiwyg editors does.
What can't you understand
I have form and i want to get te text area value on post SO IF THERE ARE NEW LINES IN THE VALUE OF THE TEXT AREA I WANT WHEN I OUTPUT THE TEXT THAT THE FORM GETED THOSE NEW LINES TO BE DISPLAYED AS ACTUALY NEW LINES LIKE THE WYSIWYG EDITORS>
Line breaks are interpreted as \n
.
With javascript you can use regular expression to detect the new line character.
regex:
/\n/
UPDATE:
var newStr = "String with line breaks".replace(/\n/g,"<br />");
this will replace the new line in textarea with <br>
tag to make a new line
You can use a regular expression in JavaScript to search for new line character RegExp("\n")
.
精彩评论