title: combine validation functions in jquery and replace class name
body: <p>I'm validating my form for required fields, and wish to replace the class "standard_input" with the class "standard_input_error" but my following code won't work. Also, is it possible to combine functions so that I don't need to write a function for each id that requires validation (there are some text fields that don't require validation, so I can't use it for the entire form). Thanks in advance.</p>
  
  <pre><code>$('#firstname').blur(function()
  {
      if( !$(this).val() ) {
            $(this).addClass('standard_input_error');
      }
  });
  
  
  Firstname * &lt;input type="text" id="firstname" name="firstname" class="standard_input"&gt; 
  Last Name*  &lt;input type="text" id="lastname" name="lastname" class="standard_input"&gt;
  another   * &lt;input type="text" id="another" name="another" class="standard_input"&gt; 
  another 2   &lt;input type="text" id="another2" name="another2" class="standard_input"&gt;
  Field      * &lt;input type="text" id="fieldb" name="fieldb" class="standard_input"&gt; 
  Blah blah   &lt;input type="text" id="blah" name="blah" class="standard_input"&gt;
  
  Checkbox 1* &lt;input type="checkbox" checked="checked" id="cbox1" name="cbox1" /&gt;
  Blah bla 1 &lt;input type="checkbox" checked="checked" id="blabla" name="blabla" /&gt;
  Blee blee1* &lt;input type="checkbox" checked="checked" id="blee" name="blee" /&gt;
  bloblo 1   &lt;input type="checkbox" checked="checked" id="blo" name="blo" /&gt;
  </code></pre>