Hello,
I'm using the function below in a JS file in order to prevent users from accidentally submitting a form on enter key hit.
But I would like to disable this script on one form only (login form), without altering the JS file, and keeping in mind that there might be other forms displayed on the page that still need the script.
Does anyone have an idea on how to do that?
Code:
var nav = window.Event ? true : false;
if (nav) {
window.captureEvents(Event.KEYDOWN);
window.onkeydown = NetscapeEventHandler_KeyDown;
} else {
document.onkeydown = MicrosoftEventHandler_KeyDown;
}
function NetscapeEventHandler_KeyDown(e) {
if (e.which == 13 && e.target.type != 'textarea' && e.target.type != 'submit') { return false };
return true;
}
function MicrosoftEventHandler_KeyDown() {
if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit')
return false;
return true;
}
Thanks