title: How to check the length of a Textarea
body: <p>I am trying to calculate if a textarea has a length of more than zero, then run a piece of code. I can't get this to work for some reason. I would appreciate help. </p>
  
  <p>Here is my code:</p>
  
  <p><strong>Javascript</strong> (including <strong>jQuery</strong>):</p>
  
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function () {
      if ($('.comments').val().length &gt; 0) {
          $('form').attr('action', '?Email');
      }
  });
  </code></pre>
  
  <p><strong>HTML</strong>:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form action="?AddToQuote" method="POST"&gt;
      &lt;textarea name="comments" class="comments"&gt;&lt;/textarea&gt;
      &lt;input type="submit" value="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I have tried a lot of different Javascript, none of it is working. Does a Javascript <code>if</code> statement run once the HTML page has loaded? I am positive that the line within the if statement works without the if statement, I have tested it already.</p>