title: how to validate the form before submit
body: <p>I wanted to check validation of certain field before submitting a <code>form</code>.</p>
  
  <pre><code>&lt;form method="post" action="test.do"&gt;
    &lt;input type="file" id="file1" /&gt;
    &lt;input type="file" id="file2" /&gt;
    &lt;input type="file" id="file3" /&gt;
  
    &lt;input type="button" id="submitButton" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I only want to check validation of <code>id = file2 &amp; file3</code>. It should not be left blank.</p>
  
  <pre><code>$("#submitButton").click(function() {
       if(validate()){
          $(this).closest("form").submit();
      }
     });
  
  function validate() {
      /*  if blank return false else true */
    how to validate here ??
  }
  </code></pre>
  
  <p>*<em>Note : *</em> as I have hundreds of fields to check, it'd be very lengthy to use <code>id</code> for validation.  </p>
  
  <p>Is there any other way to check ?</p>