From this question, this ...
lines = foo.value.split(/\\r\\n|\\r|\\n/);
is one way to split a string, but how do I join it back with newlin
If you want to join using newline characters, just do:
lines.join("\r\n");
But if you want to display on the HTML page, you'd want to wrap each line in tags:
html = "" + lines.join("") + "";
" + lines.join("
") + "