Should jQuery’s $(form).submit(); not trigger onSubmit within the form tag?

Sorry, misunderstood your question.

According to Javascript – capturing onsubmit when calling form.submit():

I was recently asked: “Why doesn’t the
form.onsubmit event get fired when I
submit my form using javascript?”

The answer: Current browsers do not
adhere to this part of the html
specification. The event only fires
when it is activated by a user – and
does not fire when activated by
code.

(emphasis added).

Note: “activated by a user” also includes hitting submit buttons (probably including default submit behaviour from the enter key but I haven’t tried this). Nor, I believe, does it get triggered if you (with code) click a submit button.

Leave a Comment