From 9d5316e2fb4af51721cf7b11f22759811e344c77 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 22 May 2013 15:49:26 +0200 Subject: [PATCH] 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 Signed-off-by: Galen Charlton (cherry picked from commit efdf30bc476ab130b0dc4767ba38d68208eb2ca7) Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 84481e79527d8ad1c5a3393b716c17f550736857) Signed-off-by: Bernardo Gonzalez Kriegel (cherry picked from commit 84481e79527d8ad1c5a3393b716c17f550736857) --- .../prog/en/js/prevent_submit.js | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/prevent_submit.js b/koha-tmpl/intranet-tmpl/prog/en/js/prevent_submit.js index bafd42ac93..2e6d385f97 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/prevent_submit.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/prevent_submit.js @@ -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; -} + } + }); +}); -- 2.39.5