I tried to use a link as submit button, to ensure that the user have JavaScript activated. But onsubmit wasn't executed when clicking the link. First I thought that this misbehaviour was caused by the behaviours.js library. But it didn't take long to see that this awesome lib didn't have anything to do with the problem.
Explanation
After googling a little, I found the reason for this behaviour: the onsubmit-handler is only called, when the user directly interacts (in case you are interested in the why and wherefore take a look at this).
So a call by a script (form.submit()) doesn't meet this requirement, which is why the JavaScript defined in onsubmit isn't executed.
Hm, what now?
For the first time I wish that the browsers had ignored the specs (they do it too often). But it's clear: we don't have a possibility to redirect the user's interaction here.


Comments
Superman commented, on July 16, 2008 at 10:46 p.m.:
If you're calling a submit() function then you know exactly when the form is to be submitted. if you're making a form validation, why not make a function that will validate the form first, and then execute form.submit() if successful? then instead of having a link that directly submits the form, you can have it execute that function, and thus a kinda fake onsubmit. don't know what you were trying to achieve... but that's what i would do
Martin Geber commented, on July 17, 2008 at 10:29 a.m.:
The point here is that I called ``form.submit()`` and wanted ``onsubmit`` to be executed by this call. That doesn't work.
Pinchy commented, on August 3, 2008 at 3:48 p.m.:
I pondered over over this problem for a while and found the solution. If you rename the button to something other than submit, then you can call the form.submit() function in javascript/from a link.
Pinchy. http://www.199query.com
>