Last Comment Bug 243816 - Data validation and Event Order problem (onblur fires before onchange)
: Data validation and Event Order problem (onblur fires before onchange)
Status: RESOLVED DUPLICATE of bug 65581
: testcase
Product: Core
Classification: Components
Component: DOM: Events (show other bugs)
: Trunk
: All All
: -- normal with 2 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-05-17 05:27 PDT by Deepak P Joshi
Modified: 2009-11-06 20:52 PST (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
testcase (826 bytes, text/html)
2004-05-17 05:29 PDT, Deepak P Joshi
no flags Details

Description Deepak P Joshi 2004-05-17 05:27:20 PDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040219
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040219

When a text field fails validation we want to keep the focus on that field so
attempt to set the focus back onto that field. That is when we fillup the
"ERROR"(validation failure case)in the first field and press a tab, the focus
has to come back to the first field. But on pressing the tab the focus moves to
the next field.
   On normal behaviour of the browser when we press a tab, the onChange event
has to fire first than onBlur. But till mozilla latest open source release on
windows and OS/2 onBlur is firing first and onChange is firing late.

Reproducible: Always
Steps to Reproduce:
1.Run the browser
2.Opern a local html testcase
3.Fill "ERROR" in the first field of the text box.
4.Then press a tab, the focus is moves to next field(instead, whan the text
field fails validation, the focus has to stay in the first field)
5.See Event firing in the logging text box below, the onBlur event is firing
first than the onChange event. 
   
Actual Results:  
1. After filling up "ERROR"(validation failure case) in the first field and
press tab, simply the focus is moving to the next field.
2. In logging text box below, onBlur is firing first than onChange event. 

Expected Results:  
1. After filling up "ERROR"(validation failure case) in the first field and
press tab, the focus has to come back and stay in the first field.
2. In logging text box below, onChange event has to fire first then onBlur evnet
has to fire. 

From our test analysis, problem seen on mozilla latest open source release on
both windows and OS/2.
But on netscape4.61 and IE the problem is not seen. That is when validation
fails the focus is coming back and staying in the first field. From logging text
box, we 
can see onChange event is firing first and then onBlur is firing.
Comment 1 Deepak P Joshi 2004-05-17 05:29:26 PDT
Created attachment 148659 [details]
testcase
Comment 2 Boris Zbarsky [:bz] (still a bit busy) 2004-05-17 08:36:43 PDT
> On normal behaviour of the browser when we press a tab, the onChange event
> has to fire first than onBlur.

That's what I see in NS4 and Opera.  Not in Mozilla or Konqueror.

Over to events to see whether we can fix this up, but since the onblur is what
fires the onchange, as I recall....
Comment 3 Mike Kaply [:mkaply] 2004-05-20 06:03:40 PDT
Is there any way to know what the "correct" behavior is?
Comment 4 Mats Palmgren (:mats) 2006-06-30 11:54:51 PDT
Using Testcase #4 in bug 231830. The following UAs do 'onchange' before 'onblur':
IE6/XP, IE7b2/XP, all four combinations of Opera8/Opera9 on XP/Linux,
Safari(nightly)/OSX 10.4.6.
Comment 5 Mats Palmgren (:mats) 2009-11-06 20:12:01 PST
The change/blur event order was fixed by bug 357684.
Comment 6 Mats Palmgren (:mats) 2009-11-06 20:52:39 PST
The remaining problem that the focus() calls are ignored is bug 65581.
Note that you can workaround that problem using setTimeout:
setTimeout(function(){document.gapform.Field1.focus();},0);

*** This bug has been marked as a duplicate of bug 65581 ***

Note You need to log in before you can comment on or make changes to this bug.