How do you make a <textarea> recognize that pushing the enter button is a \n character?
I have a <textarea>
that I want to print the contents on the page below it. When it does this I want to make random words be omitted.
I have accomplished this. My problem is I want make it recognize when the enter button has been pushed in the <textarea>
and display that below. I want those to not ever be omitted. I have gotten it so that when a <br/>
is typed into the <textarea>
it will not omit those and it will show t开发者_运维知识库he new lines. When I tried doing that with the \n
it does not seem to recognize in the .value
of the object that the enters are \n
.
Any ideas how to fix this?
I also tried var txtAdd = document.getElementById('textLoc').value.replace("\n","<br/>");
and it did not work.
Maybe ".replace(/\n/g, '<br />');"?
I don't follow what you are trying to do, but is it possible that you need \r\n since that is the equivalent of newline on a windows machine (assuming you are running windows)?
I think its about way of saving the data first time you should use innerHTML property that you can save it with with out replacing with \n
Regards Marwan
精彩评论