How can I prevent Chrome from adding extra lines to the text box?

I have a form in asp that checks some javascript errors, shows a preview of the form information before the user submits it to our database. To enable formatting of light before a view, we replace all line breaks with tags.

<textarea name="DATA_Description" ROWS=30 wrap=on cols="30"><%=DATA_Description%></textarea> 

Replacing a line break with

 <%=replace(DATA_Description,vbcr,"<BR>")%> 

This works great in all browsers except Chrome. Chrome adds an extra line break at the end of each line in the text box. We use text in several width areas with several font styles, so I need line breaks to occur only when the user actually entered a hard return ...

Any suggestions?

+4
source share
2 answers

You replace the carriage return, not the line feeds that appear in the text box. I would not be surprised if Chrome on Windows used CRLF instead of LF, and I would not expect CR-only.

+1
source

I always used vbcrlf instead of vbcr when I took the data from the text area that was saved in the database and wanted to show it as html instead of back in the text box (using a replacement like you did).

I never tested what would happen if I used Linux or Mac, which used only LF instead of CRLF (then there was no need to worry about Mac and Linux support). And now, when I think about it, it seems to me that using CRLF or LF is part of the HTML specification and is the same for all operating systems for any text field? Hmmm.

0
source

All Articles