Bug 10310: Prevent submitting form with enter does not work with IE

I am not able to test this patch with IE...
I tested it with Chromium and FF and it works great.

This patch can be tested on the neworderempty.pl page
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Jonathan Druart 2013-05-22 15:49:26 +02:00 committed by Galen Charlton
parent 646015c647
commit efdf30bc47
1 changed files with 10 additions and 17 deletions

View File

@ -1,18 +1,11 @@
var prevent_nav = window.Event ? true : false;
if (prevent_nav) {
window.captureEvents(Event.KEYDOWN);
window.onkeydown = NetscapeEventHandler_KeyDown;
} else {
document.onkeydown = IEEventHandler_KeyDown;
}
function NetscapeEventHandler_KeyDown(e) {
if (e.which == 13 && e.target.type != 'textarea' && e.target.type != 'submit') { return false; }
return true;
}
function IEEventHandler_KeyDown() {
if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit')
$(document).ready(function() {
// We don't want to apply this for the search form
$("#doc3 form").keypress(function (e) {
if( e.which == 13
&& e.target.nodeName == "INPUT"
&& $(e.target).attr('type') != "submit"
) {
return false;
return true;
}
}
});
});