1

For IE, I tried several ways to add new lines in textarea without success.

HTML

<textarea name="myTextarea" rows=4 cols=4 maxlength=250></textarea>

JAVASCRIPT

var text= "line1 line2 line3";              
text= text.replace(/\s/g, "\r");
$('textarea[name=myTextarea]').val(text);

UPDATE

I tried to remove the css associate to the textarea and its work.

textarea{
   white-space: nowrap;
 }

The problem is that now I cannot display words in the same line without breaking them. But it requires another question

Jils
  • 783
  • 5
  • 12
  • 32

1 Answers1

1

Your code works fine. I just tried in IE: http://jsfiddle.net/yo6cc45g/

The problem is that you set cols=4 and line1 contains 5 characters, therefore the number will appear in a new line. Just change the cols attribute to 5 and it will be ok.

<textarea name="myTextarea" rows=4 cols=5 maxlength=250></textarea>
enb081
  • 3,831
  • 11
  • 43
  • 66