Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, instead of <strong>finding</strong> the line breaks (which is virtually impossible) you can <strong>force</strong> them into the textarea, using this function:</p> <pre><code>function ApplyLineBreaks(strTextAreaId) { var oTextarea = document.getElementById(strTextAreaId); if (oTextarea.wrap) { oTextarea.setAttribute("wrap", "off"); } else { oTextarea.setAttribute("wrap", "off"); var newArea = oTextarea.cloneNode(true); newArea.value = oTextarea.value; oTextarea.parentNode.replaceChild(newArea, oTextarea); oTextarea = newArea; } var strRawValue = oTextarea.value; oTextarea.value = ""; var nEmptyWidth = oTextarea.scrollWidth; var nLastWrappingIndex = -1; for (var i = 0; i &lt; strRawValue.length; i++) { var curChar = strRawValue.charAt(i); if (curChar == ' ' || curChar == '-' || curChar == '+') nLastWrappingIndex = i; oTextarea.value += curChar; if (oTextarea.scrollWidth &gt; nEmptyWidth) { var buffer = ""; if (nLastWrappingIndex &gt;= 0) { for (var j = nLastWrappingIndex + 1; j &lt; i; j++) buffer += strRawValue.charAt(j); nLastWrappingIndex = -1; } buffer += curChar; oTextarea.value = oTextarea.value.substr(0, oTextarea.value.length - buffer.length); oTextarea.value += "\n" + buffer; } } oTextarea.setAttribute("wrap", ""); } </code></pre> <p>This function get ID of textarea and whenever there is word wrap, it push new line break into the textarea. Run the function in the form submit and you will get the text with proper line breaks in the server side code.</p> <p>Tested successfully for IE, Chrome and Firefox feel free to see for yourself here: <a href="http://jsfiddle.net/yahavbr/pH79a/1/" rel="noreferrer">http://jsfiddle.net/yahavbr/pH79a/1/</a> (The preview will show the new lines)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload