title: How can I validate input fields with Twitter Bootstrap 2.0 and apply error class?
body: <p>I have a field like the following:</p>
  
  <pre><code>&lt;div class="control-group"&gt;
      &lt;label class="control-label" for="lname"&gt;Last Name&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;input class="span3" type="text" id="lname" name="lname" placeholder="Last Name" value=""/&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm trying the following jquery to validate some input and add the error class if needed:</p>
  
  <pre><code>var div = $("#lname").parent("div.control-group");
  ....
  div.removeClass("success");
  div.addClass("error");
  </code></pre>
  
  <p>Ideally I need to loop through several input and select fields to do my validation.</p>
  
  <p>My current code isn't adding the error class.  Any idea why?</p>