From df13aeee3bfe4e3789ed731b8028277d09853356 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 15 Sep 2008 11:33:32 -0500 Subject: [PATCH] Adding javascript to prevent premature submission of forms when using a barcode scanner (or by hitting the enter key). Addresses Bug 2591 Signed-off-by: Galen Charlton --- .../intranet-tmpl/prog/en/js/staff-global.js | 20 ++++++++++++++++++- .../prog/en/modules/cataloguing/additem.tmpl | 3 +++ .../en/modules/members/memberentrygen.tmpl | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js index bcfee94927..0ee4af2147 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js @@ -69,4 +69,22 @@ YAHOO.util.Event.onContentReady("changelanguage", function () { YAHOO.util.Event.addListener("showlang", "click", onYahooClick); YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionoMenu); - }); \ No newline at end of file + }); + +// http://jennifermadden.com/javascript/stringEnterKeyDetector.html +function checkEnter(e){ //e is event object passed from function invocation + var characterCode; // literal character code will be stored in this variable + if(e && e.which){ //if which property of event object is supported (NN4) + e = e; + characterCode = e.which; //character code is contained in NN4's which property + } else { + e = event; + characterCode = e.keyCode; //character code is contained in IE's keyCode property + } + + if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key) + return false; + } else { + return true; + } +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl index b2a1ba10d9..740a47a697 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl @@ -3,6 +3,9 @@