PDA

View Full Version : cancelling an event


Vermelh0
08-13-2002, 10:55 PM
I have a textbox with the onchange and onblur events defined.
My problem is that if the onchange event is called I want to cancel the onblur event.
Also, I need to make the onchange event process before the onblur event.
Is this possible with javascript?
Thank you,
V

adios
08-13-2002, 11:26 PM
The blur event is already fired after the change event. Try this:

<html>
<head>
<title>untitled</title>
</head>
<body onload="document.forms[0].elements[0].focus()">
<form>
<input type="text" size="24" value="change something here"
onchange="this.noblur=confirm('Event: '+event.type+'\n\nCancel onblur handler?')"
onblur="if(this.noblur)this.noblur=false;else alert('Event: '+event.type)">
</form>
</body>
</html>

Vermelh0
08-14-2002, 11:51 PM
Thanks for the help...
Just one question, which is puzzling me. That nofocus property that you're accessing is not a default property of the textbox, right? That is a new property that you created, right????
Thanks,
V

adios
08-15-2002, 12:12 AM
You got it (why use a 'global' - a window property - when there's a more logical namespace for a flag like this one?).