title: jquery if siblings hasClass
body: <p>I have the following jQuery which checks a form on submission:</p>
  
  <pre><code>$('#register_button').click(function (e) {
      var valid = true;
      $('.controls input').each(function () {
          if ($(this).siblings().hasClass('error')) {
              valid = false;
              alert('errors!');
              e.preventDefault();
              return false;
          }
      });
  });
  </code></pre>
  
  <p>Here is my HTML structure for an input:</p>
  
  <pre><code>&lt;div class="controls"&gt;
      &lt;input type="text" name="register_postcode" id="register_postcode" value="&lt;?=(isset($_REQUEST['register_postcode']) ? $_REQUEST['register_postcode'] : 'xxxxxx')?&gt;" /&gt;                    
      &lt;div class="info"&gt;&amp;nbsp;&lt;/div&gt;
      &lt;div class="valid" style="display:none;"&gt;&amp;nbsp;&lt;/div&gt;
      &lt;div class="error" style="display:none;"&gt;&amp;nbsp;&lt;/div&gt;
  &lt;/div&gt; 
  </code></pre>
  
  <p>When submitting the form and there are errors the alert shows.</p>
  
  <p>But when I submit the form and there are no errors, the alert still shows and the form isnt submitted.</p>
  
  <p>Any ideas?</p>