I have a textarea that is populated with mysql data using .val ()
It turns out that when writing line breaks or spaces in that textarea, it returns the error SyntaxError: unterminated string literal.
so I read here because I have to escape the text closing quotation marks and putting a + but of course I can not do it since it is a dynamic field and if I tell the user that he has to put the + in each line I know he will not do it and he will destroy me on the web.
Is there any way to escape from that?
I've tried using str_replace(array("\r", "\n"), '', $str);
and it does not give the error, but it does not do the line breaks and I need them: (
and if I put preg_replace("/\r\n|\r|\n/",'<br />',$str);
it changes the spaces for <br/>
but when it gets in the textarea it does not interpret them as html and it writes them literally.