When data is saved from a textArea and the data contains carriage returns(Enter key) then if the data is displayed in a text area in another form it will display properly.
However, if you try and display the same text/data as a normal html it will display it but will not consider the carriage returns and all the data will be displayed in a single line.
This can be achieved by:
var data=//get data from the text area
data=data.replace(/\r\n|\r|\n/g,"<br /> ");
now this data can be displayed as html
However, if you try and display the same text/data as a normal html it will display it but will not consider the carriage returns and all the data will be displayed in a single line.
This can be achieved by:
var data=//get data from the text area
data=data.replace(/\r\n|\r|\n/g,"<br /> ");
now this data can be displayed as html
No comments:
Post a Comment