title: Form onsubmit versus submit button onclick
body: <p><strong>UPDATE</strong>
  From <a href="https://twitter.com/BrendanEich/status/349934275208028161" rel="nofollow noreferrer">@BrendanEich</a>
  ‏</p>
  <blockquote>
  <p>@mplungjan onclick of submit just falls out of that being a button; form onsubmit is clearly better.</p>
  </blockquote>
  <hr />
  <p>Which would be the reasons to ever use the onclick of a submit button to determine whether or not the form should be submitted?</p>
  <p>I believe strongly that</p>
  <ol>
  <li>to execute something before submit and cancel the submit in case of error, the form's onsubmit event is the obvious place to put it</li>
  <li>If you use the onclick of a submit button and later decide to use type=&quot;image&quot; the event handler will fail in many browsers</li>
  <li>if you change the submit to a button, you will have to add a submit to the onclick event handler too.</li>
  </ol>
  <p>I am looking for strong reasons to prefer using a submit button's onclick event over the form's onsubmit.</p>
  <p>UPDATE: Please note that I am personally well aware of many of the issues around form submission and validation.</p>
  <p>For example that submitting by javascript will not trigger the onsubmit
  <a href="http://jsfiddle.net/mplungjan/3A4Ha/" rel="nofollow noreferrer">http://jsfiddle.net/mplungjan/3A4Ha/</a></p>
  <pre><code>&lt;form onsubmit=&quot;alert('onSubmit called')&quot;&gt;
      &lt;input type=&quot;text&quot; value=&quot;This will submit on enter but in IE the onclick is not triggered&quot; style=&quot;width:100%&quot;/&gt;&lt;br/&gt;
      &lt;input type=&quot;submit&quot; onclick=&quot;alert('Clicked')&quot; /&gt;
  &lt;/form&gt;&lt;br /&gt;
  &lt;a href=&quot;#&quot; onclick=&quot;alert('Submitting by script'); return false&quot;&gt;Submit by script will not trigger onsubmit&lt;/a&gt;
  </code></pre>
  <p>Also that IE will not trigger the onclick if you hit enter in the form in my fiddle</p>
  <hr />
  <p><strong>History:</strong></p>
  <p>Got into a discussion here</p>
  <p><a href="https://stackoverflow.com/questions/6899883/html-button-not-clickable-without-being-disabled/6899961#6899961">html button not clickable without being disabled</a></p>
  <p>I have an intense dislike of using the onclick of a submit button for ANYTHING due to <strong>many</strong><sup>1</sup> years of seeing this not work in a number of browsers, mostly older version of IE.
  I have listed a few of the obvious reasons, but I am sure they will not convince the hardened user.</p>
  <p>Can SO's community help me nail this one to the wall, like they nailed w3schools?
  Also feel free to give comments as to how I can phrase this question in an acceptable manner.</p>
  <hr />
  <p><sup>1: since the days of NS2.x and IE3.02</sup></p>