Disable the Enter key in web forms

Insert the code below in the OnKeyPress event of the form to disable the ENTER key. This code will work for both IE and Netscape
JavaScript


// key is ascii keycode
var key = ((navigator.appName == "Netscape") ? event.which : event.keyCode)
// enter is ASCII 13
var isEnter = key == 13
if (isEnter) {
   return false
} else
   return true 

Images/Screenshots:

Posted by fbrefere001 on Thursday September 12, 2002