incorrect order of javascript event process associated with object in a Form




14 years ago
12 years ago


(Reporter: Dan, Assigned: Blake Ross)


Firefox Tracking Flags

(Not tracked)



(1 attachment)



14 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040206 Firefox/0.8
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040206 Firefox/0.8

Having a Form with onsubmit event associated with it and a onkeyup event
associated with an input type text object to validate the user input.
The function associated with the input object check if the user press Return key
and in that case return "false", but the onsubmit event and\or the form itself
take precedence in the detect of the Return key and execute the POST.
The beavhior is different in IE where the function associated with the objects
in the form takes the precedence over The Form.

Reproducible: Always
Steps to Reproduce:
1. function checkInt(ObjectName,e) {
if(ie) {
  key = event.keyCode;
 } else key = e.which;

 if (( key < 48 || key > 58 ) && (key != 8 && key != 9)) {
    if(!ie) {
      ObjectName.value = ObjectName.value.substr(0, ObjectName.value.length-1);
 return false;

2. <form name="MyForm" action="main.html" method="post" target="_self"
onsubmit="return verifyBlank();" >
<input name="Number" type="text" value="" onkeyup="return checkInt(this, event);" >
<input type="submit" value="Send" name="submit"  >

3. Type some numeric and char in the input field, then press return

Actual Results:  
The function verifyBlank() will be execute and the form submited 

Expected Results:  
The Form will not be submited if the focus is in the text field and the key
pressed was Return

Comment 1

13 years ago
event firing order is different from ie.

<td class=RequiredPrompt title="Required Prompt">Check Sequence Number</td>
<td colspan=1 title="Enter the Check Sequence Number.">
<input type=Text size=1 class=text  id=CheckSequenceNumber
name=CheckSequenceNumber tabindex=4 value="<%=oObject("CheckSequenceNumber")%>"
onchange="alert('onchange')" onblur="alert('onblur');">

Firefox (Mozilla/5.0(Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107
Firefox/1.0) fires onblur, then onchange;
 Internet Explorer (6.0.2900.2180) fires onchange, then onblur.

Comment 2

13 years ago
Created attachment 182355 [details]
Document demonstrating illogical JavaScript event-firing

Comment 3

13 years ago
Confirmed under FireFox 1.03, Win32.

If you are editing a text field in IE, and click a submit button while the text
cursor is in the text field, the textfield's onchange event fires, and the form
*does not* submit.  When the onchange event completes, you are then able to
click the submit button and have the form submit.   This is logical.

In Firefox however, when you click a submit button under the exact same
scenario, the onchange event fires AND the form submits, but a form *SHOULD NOT*
be able to submit while client-side Javascript is still running.

Please see the attached html file for a demonstration of the situation described
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
This bug has been automatically resolved after a period of inactivity (see above
comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Last Resolved: 12 years ago
Resolution: --- → EXPIRED
You need to log in before you can comment on or make changes to this bug.