• 0

Javascript and textboxes newline (urgent :S)


Question

Hi !

I just want to know if there is a simple way for 'parsing' TextBox newlines (nl) with javascript...

Let's say I have a textbox:

<textarea name="test_box" id="test_box">this is a sample
multilines
text to show everyone</textarea>

I would like to be able to get the entire 'test_box' value (multi-lined) get in a javascript var

If I just do

var test_box_value = document.getElementById('test_box').value;

The test_box_value variable will have this value: 'this is a samplemultilinestext to show everyone'

What can be done ?

thanks.

PS: urgent

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I don't know what you mean by parse, here's a newline to html linebreak regular expression.

str.replace(/([^>])\n/g, '$1<br />\n');

Link to comment
Share on other sites

  • 0

Parsing in this context (See 'Original Post' of this thread) would mean evaluating content of computer textual input area in some ordered way would it not?

[Adjective ~] Parse is also used for (or "as in") literacy and so fourth naturally - - - - of course!

Link to comment
Share on other sites

  • 0
I don't know what you mean by parse, here's a newline to html linebreak regular expression.

str.replace(/([^>])\n/g, '$1<br />\n');

Thanks a lot ! it was not what I expected, but it will do the job quite fine.

Thanks again

(this thread may be closed).

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.