[thelist] with Enter, onBlur is preceded by onSubmit

Means, Eric D eric.d.means at boeing.com
Fri Jun 14 10:56:01 CDT 2002


>  -----Original Message-----
> From: 	Bill Haenel [mailto:bill at webmarketingworx.com]
> Sent:	Friday, June 14, 2002 10:38 AM
> To:	thelist at lists.evolt.org
> Subject:	RE: [thelist] with Enter, onBlur is preceded by onSubmit
>
> Not to break up the fun, but per chance does anyone have an answer to my
> question? Just in case you don't recall, it was "why is IE executing the
> onBlur event AFTER the onSubmit event when the form is submitted with the
> Enter key, and how do I fix it?"

Well, this is a guess, but I would assume that pressing Enter submits the
form (firing the OnSubmit), and submitting the form causes the control to
lose focus (firing the OnBlur).  Nothing about the Enter key implies that it
should cause the currently focused control to lose focus AFAIK, so the
onSubmit event has to be the one fired first.  In contrast, if they click
the Submit button, the control will lose focus on mousedown on the button
(fires onBlur), and onSubmit won't be fired until mouseup (per standard
control behavior - clicks occur on mouseup, not mousedown).

As for how to fix it... either catch the Enter key in an onChange handler,
or else (as you did) restructure the form so that the user is encouraged to
(or must)  cause the relevant control to lose focus before submitting.



More information about the thelist mailing list