title: Javascript onclick function stops HTML5 required from working
body: <p>Good day,</p>
  
  <p>I am working on a form where all my text fields have a required attribute; I noticed that when i clicked on submit required attribute does not show a pop up to validate if a field is empty.</p>
  
  <p>I have two submit buttons on my page both using an onclick submitform function; One opens up a new tab and the other submits the form and goes to a new page.</p>
  
  <p>For debugging purposes i remove the button that opens up a new tab and remove the onclick attribute on my second button and it work; I have been googling all day but i cannot seem to find the same scenario i have at the moment.</p>
  
  <p>I believe it has to do with my JS but i am not sure what to add or remove on my code; Please see my code below.</p>
  
  <p>JavaScript</p>
  
  <pre><code> function submitForm(action,newtab)
   {
      document.getElementById('add2').target = newtab ? '_blank' : '_self';
      document.getElementById('add2').action = action;
      document.getElementById('add2').submit();
   }
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code> &lt;form id="add2" action="add5.php" method="post"&gt;
   &lt;input placeholder="First Name" tabindex="1"
   name="fname" maxlength="128" size="30" required&gt;
   &lt;input placeholder="Last Name" tabindex="12"
   name="lname" maxlength="128" size="30" required&gt;
   &lt;button tabindex="3" value="Save"
   name="save" onclick="submitForm('add3.php',1);" 
   type="submit"&gt;Child Information&lt;/button&gt;
   &lt;button tabindex="4" value="Save"
   name="save" onclick="submitForm('add5.php',0);" 
   type="submit"&gt;Save Details&lt;/button&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>I have a button attribute but i have set it to type="submit" and i am pretty much sure that works as i have already tested it when i removed the onclick functions; My question is can i required attribute worked without removing the onclick function of JavaScript?</p>
  
  <p>Any help is much appreciated.</p>