User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6a) Gecko/20031002 Firebird/0.7+ Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6a) Gecko/20031002 Firebird/0.7+ According to the W3 specs, onchange is supposed to be triggered after the "control" loses focus. Currently, Mozilla triggers onchange (in a checkbox) before it loses focus. The exact wording of the spec is as follows: The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus. This attribute applies to the following elements: INPUT, SELECT, and TEXTAREA. http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.3 Reproducible: Always Steps to Reproduce: 0. Imagine you have the following code on a page: <input type="checkbox" onChange="alert('checkbox 1 - onChange')"> Basically it pops up an alert whenever onChange is triggered. You may reproduce this issue with the keyboard or mouse. 1. Using your mouse, click on the checkbox. 2. Release your mouse button alternatively, using your keyboard 1. tab over to the checkbox, so that is has focus 2. press the spacebar down to change it's value 3. release the spacebar. Actual Results: The actual results of both instances is that the onchange event is triggered. Expected Results: Instead, the onchange event should wait until the checkbox loses focus before being triggered. I will add that I believe that this was a poor design choice by W3C. I do not think they should have made it wait until focus is lost till onchange gets triggered. However it is the spec, nonetheless. Thus, I have filed it as a bug on the part of Mozilla.
Reluctantly confirming. Mozilla's behavior is what should be in the spec, and the specified behavior is next to useless. Nonethless, Mozilla does not comply with the spec. Since other browsers (notably IE) do, there's probably not much hope for getting the spec changed. I can't imagine a good solution to this problem. If the behavior is left as it is, there may be scripts that rely on the specified behavior that won't work with Mozilla. On the other hand, I *know* there are cases where Mozilla's behavior is more useful, and implementing the specified behavior will remove that behavior. There may already be scripts relying on it, accidentally or by design.
The Web Forms 2.0 spec adds oninput which would be triggered when the checkbox state changes, which would cope with this case I think.
Thanks for the info. Here's the URL I found on that: http://www.hixie.ch/specs/html/forms/web-forms-2#change Here's something interesting I noted about it: Status of this document This is a work in progress! This document is changing on a daily if not hourly basis in response to comments and as a general part of its development process. Comments are very welcome, please send them to firstname.lastname@example.org and cc email@example.com. Thank you. It is very wrong to cite this as anything other than a work in progress. Do not implement this in a production product. It is not ready yet! At all! I'm thinking of contacting them.
"them" is me. :-)
*** Bug 278065 has been marked as a duplicate of this bug. ***
The specs have been changed and now feet our behavior: "The activation behavior is to fire a simple event that bubbles named change at the element, then broadcast formchange events from the element's form owner, if any."