submit
and reset
events on formsThese test are my tentative to build a cross-browser validator method for Web Forms. The objective is being able to execute some user function before the form is really submitted to the server. The most annoying problem is that form submission doesn't always go through the "onsubmit" event handlers we may have setup. In fact by programmatically calling the form inherited "submit" method from Javascript will bypass the user "onsubmit" handler.
As always the problem is with Internet Explorer, the different behavior and the missing HTMLFormElement prototype chain is pushing us to solve in other ways. However during this small work I realized the the UI activation events are great in Internet Explorer and hope Firefox 3 will implement these method too as others have already done.
The newer version is preferred because many more situations are taken care of, the difference in how the event capturing is setup and the use of HTMLFormElement prototype replacement for W3C browsers makes the latest version more capable.
This actually let us intercept also programmatic calls directly to the "submit" method which was part of our primary goals. This should work reliably enough in Firefox, Internet Explorer, Opera, Safari and Konqueror, more tests are needed.
To fire a "submit" event programmatically use this javascript in Firebug:
document.forms[0].submit();
or type this in the location bar:
javascript:document.forms[0].submit();