title: Why does this form get submitted even if the required fields are left empty?
body: <p>I am working with a form in which i take the password input from the user and then javascript checks if the passwords match. But even if the password is required, the form gets submitted if the input box is left empty. I am using javascript to submit the form. Although i have a solution to my problem but i wanted to ask that why this is happening and not the normal action of <code>Please fill in this field</code>, which normally appears when doing so.</p>
  
  <p>HTML-</p>
  
  <pre><code>&lt;form action="check.php" method="POST" id="userform"&gt;
  USERNAME:&lt;input name="uname" type="text" required/&gt;
  PASSWORD:&lt;input type="password" id="upass" name="upass" type="text" required/&gt;
  RETYPE PASSWORD:&lt;input type="password" id="reupass" name="reupass" type="text" required/&gt;
  &lt;input type="button" value="Submit" onclick="passCheck()"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JavaScript-</p>
  
  <pre><code>function passCheck(){
  var pass1 = document.getElementById('upass').value;
  var pass2 = document.getElementById('reupass').value;
  if(pass1 == pass2){
      document.getElementById('userform').submit();
  }
  else{
      alert("Both password inputs do not match. Please retry.");
      document.getElementById('userform').reset();
  }
  }
  </code></pre>
  
  <p>EDIT-
  I want that this should appear when i click on the button and the password fields are left empty:<a href="http://i.stack.imgur.com/cGuCK.jpg" rel="nofollow">http://i.stack.imgur.com/cGuCK.jpg</a></p>