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)

x86
Windows 98
defect

Tracking

()

VERIFIED INVALID

People

(Reporter: vladimire, Assigned: jst)

References

Details

Attachments

(2 files)

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.
Attached file testcase
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?
Confirming this one.
Status: UNCONFIRMED → NEW
Ever confirmed: true
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
Attached patch patchSplinter Review
Alright, I guess you are right, marking invalid.
Status: RESOLVED → VERIFIED
mid-air collision ? / bugzilla cleanup
Reopening (current State: verified and no resolution)
Status: VERIFIED → REOPENED
invalid
Status: REOPENED → RESOLVED
Closed: 24 years ago24 years ago
Resolution: --- → INVALID
verfied
Status: RESOLVED → VERIFIED
*** Bug 243254 has been marked as a duplicate of this bug. ***
*** Bug 321737 has been marked as a duplicate of this bug. ***
*** Bug 171020 has been marked as a duplicate of this bug. ***
*** Bug 360249 has been marked as a duplicate of this bug. ***
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.

Attachment

General

Created:
Updated:
Size: