title: How to display messages in invalidHandler in JQuery validator
body: <p>I'm trying to use the JQuery validator on a form and am trying to figure out to get the messages of the errors in the invalidHandler option (or if there's somewhere else, do tell).</p>
  
  <p>When a user clicks the submit button, whatever the first error is, I want to display an alert box with the message of the error. I don't want the error to be written on the document. I can't seem to figure out how to get the error messages to use in an alert after validation. I only found how to get the elements, and that doesn't really help me.</p>
  
  <p>Pulling out from the example, here's some code I'm testing with</p>
  
  <pre><code>$(document).ready(function() {
      $('#commentForm').validate({
          invalidHandler: function(f, v) {
              var errors = v.numberOfInvalids();
              if (errors) {
                  var invalidElements = v.invalidElements();
                  alert(invalidElements[0]);
              }
          }
      });
  });
  </code></pre>
  
  <p>and</p>
  
  <pre><code> &lt;form class="cmxform" id="commentForm" method="get" action=""&gt;
   &lt;fieldset&gt;
     &lt;legend&gt;A simple comment form with submit validation and default messages&lt;/legend&gt;
     &lt;p&gt;
       &lt;label for="cname"&gt;Name&lt;/label&gt;
       &lt;em&gt;*&lt;/em&gt;&lt;input id="cname" name="name" size="25" class="required" minlength="2" /&gt;
     &lt;/p&gt;
     &lt;p&gt;
       &lt;input class="submit" type="submit" value="Submit"/&gt;
     &lt;/p&gt;
   &lt;/fieldset&gt;
   &lt;/form&gt;
  </code></pre>