Twitter Feed

Xataface Maillist

Sign up to receive the Xataface news letter with weekly updates and development tips.

 

How to disable the Enter key in forms.

This function ignores the Enter key while editing or adding new records. This is useful when using barcode scanners to enter data or simply to avoid incomplete form submissions. Tested with Mac Firefox, Safari and IE.

1) Add the following attribute to any of the fields in the "fields.ini" file:

widget:atts:onkeypress="stopEnterKey(event.keyCode);"

2) Insert the following function in one of the existing javascript files used by your application, or create your own:

function stopEnterKey(evt) {

var evt = (evt) ? evt : ((event) ? event : null);

var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);

if ((evt.keyCode == 13) && (node.type=="text")) {return false;}

document.onkeypress = stopEnterKey;

}

3) That's it!

Powered by Xataface
(c) 2005-2017 All rights reserved