Monday, January 19, 2009

JS: Disable Enter Key

The following javascript, helps to ignore Enter key



function disableEnter(e) {
e = (e) ? e : (window.event) ? event : null;

if (e) {
var charCode = (e.charCode) ? e.charCode :
((e.keyCode) ? e.keyCode :
((e.which) ? e.which : 0));

if (charCode == 13) {
e.returnValue = false;
}
}
}

Hope it helps! Happy Coding

No comments:

Post a Comment