title: Returning false in Javascript/Jquery within an if statement
body: <p>I've got this function to check my form:</p>
  
  <pre><code>function checkFrm() {
      $.each($('select'), function() {
          var $this = $(this);
  
          if( $this.val() === 'null') {
              // do nothing
          } else {
              if($this.next('input').val().length &lt; 1) {
                  return false;
              }
          }
      });
  }
  </code></pre>
  
  <p>When the user submits this, it runs this code, and ideally if the criteria is met the form won't submit because of the 'return false;' bit.</p>
  
  <p>However, for some reason it's completley ignoring this!</p>
  
  <p>If I set a return variable at the start like 'var toreturn = true;' then set 'toreturn = false' when the trigger is hit, then 'return toreturn;' right at the end it stops the form submitting just fine... however that's not much use, as the alerts and checks I run in between are all triggered at once which would be completely overwhelming for the user.</p>
  
  <p>Any suggestions please?</p>
  
  <p>Cheers :)</p>