title: JSP textarea length check issues
body: <p>I have tried to use some of the max length functions found here, but I am running into some issues with them. I have tried to check the length of the form when the user presses a submit button, but the value in the variable does not change until the form is being submitted. Below is the relevant code:</p>
  
  <pre><code>&lt;tr&gt;
  &lt;td align="left"&gt;&lt;b&gt;Comments:&lt;/b&gt;&lt;br&gt;
  &lt;form:textarea path="currentProjTask.comments" id="currComments" cols="100" rows="10" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>Below is the code that creates a popup. The value will always be whatever the value was when the page was loaded, until it gets to the $("#command").submit(); line, then it will be whatever the user has entered.</p>
  
  <pre><code>var newcomments = document.getElementById("currComments").value;
  var currentcomments = newcomments.length;
  alert("currentcomments = " + currentcomments + " newcomments = " + newcomments);
      $("#command").submit();
      var newcomments = document.getElementById("currComments").value;
  var currentcomments = newcomments.length;
      alert("currentcomments = " + currentcomments + " newcomments = " + newcomments);
  </code></pre>
  
  <p>I have tried many different ways to check the length, including functions for key presses etc, and none of those worked, yet none of them threw any errors.</p>
  
  <p>I appreciate your help in advance, thank you very much.</p>
  
  <p>EDIT for clarity:</p>
  
  <p>The functions that I have tried have done nothing. For example, if I add in onkeydown='return maxLength(this,"30");' to the textarea block, and the function </p>
  
  <pre><code>function maxLength(field,maxChars)
  {
     if(field.value.length &gt;= maxChars) {
        event.returnValue=false; 
        alert("more than " +maxChars + " chars");
        return false;
       }
  
  }  
  </code></pre>
  
  <p>This does nothing. The user can still type and submit the form.</p>
  
  <p>With the alert box where I get the document.getElementById (when the user hits the submit button), the value received is the initial value of form on load of the page. A user can change the value in the text area, but the value in the alert box will always be the initial value in the box.</p>
  
  <p>I should also mention this is a .jsp page.</p>