Search code examples
htmlpostnewlinehidden-fieldcarriage-return

Post newline/carriage return as hidden field value


I need to post multi-line data via a hidden field. The data will be viewed in a textarea after post. How can I post a newline/carriage return in the html form?

I've tried \r\n but that just posts the actual "\r\n" data

<input type="hidden" name="multiline_data" value="line one\r\nline two" />

Is there a way to do this?


Solution

  • Depends on the character set really but &#10; should be linefeed and &#13; should be carriage return. You should be able to use those in the value attribute.