title: Use of setCustomValidity in form requires two clicks for onsubmit
body: <p>I am working on a form that makes use of the HTML5 form validation attribute <code>required</code> for various <code>text</code> and <code>radio</code> button fields. The form also has two sets of checkboxes, of which at least one checkbox must be checked.</p>
  
  <p>In order to keep the user error feedback consistent I am using the <code>setCustomValidity</code> method to throw a native error bubble when the checkboxes are left unchecked. This all works fine, however, there is an issue with error feedback when the form is submitted and the <code>onsubmit</code> event is used to trap unchecked checkboxes. This issue doesn't arise when the <code>onclick</code> event is bound to the submit button instead, but I understand it is preferable to use <code>onsubmit</code>.</p>
  
  <p><strong>Onclick test case (Click submit button and error bubble appears first time!)</strong>
  <a href="http://jsfiddle.net/Jimadine/bZe5e/" rel="noreferrer">http://jsfiddle.net/Jimadine/bZe5e/</a></p>
  
  <p><strong>Onsubmit test case (Click submit button - error bubble appears after second click)</strong>
  <a href="http://jsfiddle.net/Jimadine/2vLszqac/" rel="noreferrer">http://jsfiddle.net/Jimadine/2vLszqac/</a></p>
  
  <p>Furthermore, from my testing of the onsubmit case, Firefox highlights the unchecked checkboxes after the first click of the submit button; this is indicated by a red glow around the checkboxes. Then after a second click the error bubble displays. In other modern browsers the first click displays no on-screen indication that the checkboxes were left unchecked; I presume this is how the UX side of HTML5 validation was implemented in these browsers and that Firefox chose to do things slightly differently.</p>
  
  <p>My question is why does the onsubmit test case require two clicks and what is an appropriate way to rectify this so it behaves like the onclick test case? I'm guessing it has something to do with the submit event firing after the validation but I'm not sure how to correct my code.</p>