[html5] onclick vs. onsubmit
jblist at me.com
jblist at me.com
Thu Mar 24 14:03:00 PDT 2011
Hi folks,
I have a form with two submit buttons. Based on which submit button is clicked, I'd like to present different confirmations prior to allowing the submission to proceed. Originally, I just used the onclick attribute with a function that essentially called confirm(). Returning false would cancel the submission. Each button had its own click event handler and everything was working as expected.
However, in attempting to make sure my markup is correct, I passed my page through the validator which complained about the return value in the click event handler. The error message was a bit cryptic, but I'm assuming that click events are not supposed to be cancelable (even though the browsers let me do that).
To do the "right thing" I figured I need to hook my javascript into the submit event stream instead. However, how can I determine which submit button fired the submission? Is this encoded in the submit event? Is there some state in the button itself I can query from the event handler? What's wrong with returning false from the click event handler to stop the form submission?
Best regards,
Joe
More information about the Help
mailing list