tags:

views:

193

answers:

2

I have a textarea. When I paste text with line breaks into it, the line breaks are automatically removed. But when I manually enter line breaks (hitting carraige return), they are preserved.

How do I force the textarea to preserve line breaks with pasted text?

A: 

The line breaks are always preserved when pasted on textarea.

Maybe the source have a different line break, you are copying from what program?

charles.art.br
A: 

Don't know if this applies to all browsers, but in Google Chrome (6 and 7), line breaks in pasted text gets removed if the textarea's style is set to white-space: nowrap;.

I used this style setting to prevent the default wrapping of long lines and experienced the same problem as yours. Later I realized that setting the textarea attribute wrap to off does a much better job. Be aware that wrap="off" is widely supported but not standardized.

Oben Sonne