title: 'onclick' doesn't seem to call a function with 'submit' button
body: <p>I've come across this many times ( I don't want to use 'input type button' here ) why oh why the 'onclick' doesn't call the function check(); ? The page still submits even when the fields are empty. Thank you for your comments.</p>
  
  <p>Javascript:</p>
  
  <pre><code>function check() { 
      var name =  document.getElementById('username_res');
      var passw_old =  document.getElementById('passw_reset_old');
      var passw_new =  document.getElementById('passw_reset');
      var button_res = document.getElementById('sub_res');
  
      if ((name.val() == "") &amp;&amp; (passw_old.val().length == "") &amp;&amp; (passw_new.val().length == "")) { 
          button_res.disabled = true; 
      } else {
          button_res.disabled = false;
      }
  }
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form id="passw_res" name="passw_res" method="post" action="pass_reset.php"&gt;
  &lt;fieldset style="width:300px"&gt;&lt;br/&gt;
  &lt;legend id="pass_legend" align="left"&gt;Password reset&lt;/legend&gt;&lt;br/&gt;
  &lt;input type="text" id="username_res" name="username_res" maxlength="50" /&gt;
  &lt;input type="password" id="passw_reset_old" name="passw_reset_old" maxlength="16"/&gt;
    &lt;input type="password" id="passw_reset" name="passw_reset" maxlength="16"  /&gt;
    &lt;input type="submit" value="submit" id="sub_res" name="sub_res" onclick="check();"/&gt;
   &lt;/fieldset&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>So...the page shouldn't submit on empty fields - why does it submit ? Thanks..</p>