...

View Full Version : (IE) Stopping propagation of ESC keydown event in form AFTER the active field reset



rm-f
08-20-2005, 09:03 PM
On an ESC keydown event, the IE resets entire form. I am looking for solution where ESC resets ONLY the active input field of the form.


if (document.all)
document.onkeydown = function () {
return event.keyCode != 27;
}

prevents ALL resets, that is not what I am looking for.

tnx,
rm -f

subhailc
08-20-2005, 11:05 PM
would this not work?
document.onkeydown = function () {
if(event.keyCode==27) {
event.srcElement.value = '';
return false;}}

rm-f
08-21-2005, 12:03 AM
event.srcElement.value = '';
sets value to nothing not to previous value.

Lets say the original value was:
ABCD
the value has been changed to:
ABCDefgh
after ESC has been pressed the value should be:
ABCD

glenngv
08-22-2005, 01:51 PM
You can get the original value of a textbox by accessing the defaultValue attribute.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum