On Thu, 29 Apr 2004 20:52:04 GMT, Grant Wagner
[snip]
Event handlers can't "undo" anything, but they can prevent the action
that triggered the event from "bubbling up" and being handled by some
other aspect of the Web browser or operating system.
Bubbling and cancelling are two completely different things, and you
appear to have confused them.
Assuming event propagation isn't interrupted, a dispatched event will flow
from the document root in a pre-determined route towards the target
element, firing any capturing listeners as it goes[1]. Once it reaches the
target, it fires all of the listeners there (except capturing listeners),
and then bubbles back up the document tree the way it came. Once the event
reaches the document root again and has finished firing all listeners, the
browser then, and only then, performs the default action for that event
type (if one exists).
If, at any point, a listener returns false (in the old model), calls
preventDefault() (in the DOM model) or sets returnValue to false (in the
IE model), the event continues as I previously described except that the
default action is not executed. No change to the event flow occurs.
Under the IE and DOM event models, you can stop propagation during any of
the three phases: capture, at target, or bubbling. You do this in IE by
setting the cancelBubble property of the event to true, or by calling
stopPropagation() method of the event. All listeners on the current
element fire, but the event will not proceed to the next element. If the
event hasn't been cancelled, the default action will then occur.
[snip]
function validate(f) {
if (f.someInput && f.someInput == 'some value') {
return true;
} else {
return false;
}
}
Wouldn't it be better to write...
return( f.someInput && ( f.someInput == 'some value' ));
....?
[snip]
Mike
[1] It should be noted that IE doesn't support event capture, so this
phase is skipped.