Jim Ley wrote:
On Mon, 21 Jul 2003 17:36:06 GMT, Grant Wagner
<gw*****@agricoreunited.com> wrote:
Stuart Wexler wrote:
Hi,
I have a form with onSubmit embedded in the <form>
tag. The form is submitted programatically through
javascript [ie... form.submit()]. While the form submits fine, nothing
I'm doing seems to get it to also register the code in the onSubmit event.
Any suggestions as to why this is happening or how to resolve it?
-Stu
Yes, this is correct behavior. the onsubmit event does not fire if you call
document.forms['yourForm'].submit();
It's documented correct in IE, but to standards it's wrong, a lot of
pages would break right now if the correct spec following was done...
I'd play safe and always call onsubmit manually, then remove it, then
submit.
Jim.
I asked a while back about this and received a reply at the time that seemed to
indicate onsubmit should not fire when submit() is called, but it's certainly
possible the person responding was incorrect.
As for browser support, IE 4+, Netscape 3+ and Opera up to 6 did not call onsubmit
when submit() was invoked. It seems that Opera 7.x does, which can lead to all
sorts of nasty surprises if you both manually call the validation routine and have
it called as part of an onsubmit event.
So you're right, remove the onsubmit event from the form and always call it
manually if you are invoking submit() anywhere. Better yet, avoid calling submit()
directly wherever possible.
--
| Grant Wagner <gw*****@agricoreunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
*
http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
*
http://www.mozilla.org/docs/web-deve...upgrade_2.html