2

here i'm copying the contents from webpage and pasting the contents in form fields like textarea. while retrieving the form contents, escape characters are also coming along which is breaking the functionality. how to avoid the escape characters and retrieve only the given text. The escape characters are not visible in the form fields, but its visible in json.

Text area given text

enter image description here

the above 1st image is entered text and second image is retrived in json. Help me out in this Thanks.

manoji stack
  • 709
  • 1
  • 11
  • 27
  • 1
    make it normal `` if you don't want a linebreak – rrk Jul 24 '15 at 07:17
  • That character is a newline and is part of the content. Other characters you might encounter are `\r` and of course `\"`. If you don't want them, you can use `replace` to remove them from the content. – GolezTrol Jul 24 '15 at 07:17
  • 1
    `escape characters are also coming along which is breaking the functionality` This is expected behaviour and imho shouldn't be changed. So instead explain what it is breaking??? – A. Wolff Jul 24 '15 at 07:18

1 Answers1

1

Try to remove the line breaks with this line of code:

text = text.replace(/(\n|\r)/gm,"");

Cf: How to remove all line breaks from a string?

Community
  • 1
  • 1
Vico
  • 1,696
  • 1
  • 24
  • 57