Closed
Bug 45190
Opened 24 years ago
Closed 24 years ago
form.submit() does not run onsubmit event
Categories
(Core :: DOM: Core & HTML, defect, P3)
Tracking
()
VERIFIED
INVALID
People
(Reporter: vladimire, Assigned: jst)
References
Details
Attachments
(2 files)
291 bytes,
text/html
|
Details | |
1.27 KB,
patch
|
Details | Diff | Splinter Review |
BUILD: 2000070920 STEPS TO REPRODUCE: Open the attached test case. Click on the "Submit Input" button. Then click on the "JavaScript submit()". EXPECTED RESULT: An alert box saying "ONSUBMIT worked" would pop up as defined in the event handler and submition would not proceed since it was canceled by 'return false'. ACTUAL RESULT: No alert box pops up and the browser tries to submit the form.
Reporter | ||
Comment 1•24 years ago
|
||
Comment 2•24 years ago
|
||
Hm, neither Nav nor IE executes the ONSUBMIT handlers. I have a fix in my tree that would do this, but doing so might break scripts that depend on the ONSUBMIT handler not being fired. Should we add this change?
Comment 4•24 years ago
|
||
Well, this is not covered directly in the spec. I looked here: http://www.w3.org/TR/REC-html40/interact/forms.html#edef-FORM http://www.w3.org/TR/REC-html40/interact/forms.html#submit-format http://www.w3.org/TR/REC-html40/interact/scripts.html#events DOM 2 spec In a case where the spec is ambiguous, generally, we try to maintain backwards compatability with Nav and IE. In this case, that means not firing the event. There are two reasons to not fire the event: 1) Backwards compatability 2) Doing so will not impairing functionality form.submit() is being called from a script. At that point, we can just execute the code that would have been executed in the form onSubmit handler. For example, in this case: <HTML> <HEAD> <TITLE>submit.html</TITLE> <SCRIPT> function doOnSubmitThing() { alert('ONSUBMIT worked'); return false; } </SCRIPT> </HEAD> <BODY> <form name="Sean" onSubmit="return doOnSubmitThing();"> <input type="submit" value="Submit Input"> <input type="button" value="JavaScript submit()" onclick="if (doOnSubmitThing()) {document.forms[0].submit();}"> </form> </BODY> </HTML> So, I'm going to mark this bug as INVALID. Please reopen if you don't agree with this assessment. Thanks!
Status: NEW → RESOLVED
Closed: 24 years ago
Comment 5•24 years ago
|
||
Reporter | ||
Comment 6•24 years ago
|
||
Alright, I guess you are right, marking invalid.
Status: RESOLVED → VERIFIED
Comment 7•24 years ago
|
||
mid-air collision ? / bugzilla cleanup Reopening (current State: verified and no resolution)
Status: VERIFIED → REOPENED
Comment 8•24 years ago
|
||
invalid
Status: REOPENED → RESOLVED
Closed: 24 years ago → 24 years ago
Resolution: --- → INVALID
Comment 10•19 years ago
|
||
*** Bug 243254 has been marked as a duplicate of this bug. ***
Comment 11•19 years ago
|
||
*** Bug 321737 has been marked as a duplicate of this bug. ***
Comment 12•18 years ago
|
||
*** Bug 171020 has been marked as a duplicate of this bug. ***
Comment 13•18 years ago
|
||
*** Bug 360249 has been marked as a duplicate of this bug. ***
Comment 15•16 years ago
|
||
The HTML5 Spec says the following about this situation: The submit() method, when invoked, must submit the form element from the form element itself. [...] If the submitter is anything but a form element, then fire a simple event that bubbles, named submit, at form. If the event's default action is prevented (i.e. if the event is canceled) then abort these steps. Otherwise, continue (effectively the default action is to perform the submission). [ http://www.whatwg.org/specs/web-apps/current-work/#the-form-element ] So do I understand the spec correctly that it says that no submit event is fired when the submit() method is called?
You need to log in
before you can comment on or make changes to this bug.
Description
•