new line character

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mah raj
    New Member
    • Sep 2011
    • 1

    new line character

    Hi

    I have a HTML form and on click of the submit button, I pull the values from the fields using javascript, frame them as parameters and use ajax to submit the form.

    one of the fields is a textarea. If I use a new line character in the textarea, it is getting stored in the database without that ("\n\r").

    from form, the value will be like "line 1 \n\r line 2"
    but it is stored in the database as "line 1 line 2"

    I tried to replace "\n\r" with "<br />" and store it. But the AJAX request fails if I do that.

    what is the problem? any solution?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    It's probably being stored, but you need to convert it back when displaying.

    If you're going to send HTML, make sure to encode it and decode it back when displaying.

    Comment

    Working...