title: Simplest JQuery validation rules example
body: <p>The following HTML form successfully utilizes jQuery's form validation, displaying "This field is required" to the right of the form field if left blank, and "Please enter at least 2 characters" if fewer than 2 characters were entered.  However, instead of the validation metadata being specified using the class and minlength attributes on the "cname" form input field, I'd like to use jQuery's "rules" API instead, where the rules are specified in the body of the validate function.  Thanks in advance:</p>
  
  <pre><code>    &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                      "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;script src="/lib/js/jquery.js"&gt;&lt;/script&gt;
    &lt;script src="/lib/js/jquery.validate.js"&gt;&lt;/script&gt;
    &lt;script&gt;
    $(document).ready(function(){$("#commentForm").validate(
      /*
       rules/messages here
      */
      );}
      );
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
   &lt;form 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;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>