title: Javascript not working on a Visual Force page when new line character is encountered in a String
body: <p>So I noticed that a piece of Javascript on my VisualForce page was working in some cases, and wasn't in others.  JS was doing some operations on a textArea field from one of the custom objects we have.  I realized that JS was breaking whenever that textArea field had a new line or carriage return character in it (\n and \r). </p>
  
  <p>So I ended up using a replaceAll() method in the page controller, and removing all of those characters from that textArea field on page load.   By the time it got to JS, it was a legal string.</p>
  
  <p>on the VF PAGE:</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
  function someFunction() {
      var leftOver = 220;           
  
      if('{!shippingAddress.Delivery_Requirements__c}'.length &gt; 0){
          leftOver -= '{!shippingAddress.Delivery_Requirements__c}'.length;
      }                                             
  }            
  &lt;/script&gt;
  </code></pre>
  
  <p>in the controller:</p>
  
  <pre><code>//a fix for the text area field - '\n' and '\r' breaks JS on the VF page        
  shippingAddress.Delivery_Requirements__c = shippingAddress.Delivery_Requirements__c.replaceAll('\r\n', ' ');
  </code></pre>
  
  <p>Posting this as a heads up for anyone who encounters JS working for some records and not for others.</p>
  
  <p>If you have insight on why it breaks, do tell.</p>