Forum Moderators: open
Another problem with forms. When users are filling out form fields and presses the escape key (once or twice) by default most browsers automatically clears the form field of all text. Is there a way to disable this at all?
(I know... why would people press the escape key when filling out a form?.. lets just say that most of my targeted audience is not so bright with web forms)
Any feedback is appreciated.
Thank you
document.onkeydown = showDown;
function showDown(evt) {
evt = (evt)? evt : ((event)? event : null);
if (evt) {
if (event.keyCode==27 && (event.srcElement.type == "text" ¦¦ event.srcElement.type == "textarea" ¦¦ event.srcElement.type == "password") ) {
// stop escape
cancelKey(evt);
return false;
}
}
}
function cancelKey(evt) {
if (evt.preventDefault) {
evt.preventDefault();
return false;
}
else {
evt.keyCode = 0;
evt.returnValue = false;
}
}