Prevent Enter From Submitting Form

Using a form with several text fields and a submit button? Want to force the user to use the submit button instead of the ENTER key? Disable the ENTER Key!

Instead of using
<input type="submit" value="Submit">
Use this instead
<input type="button" value="Submit" onClick="call a javascript function">

In your javascript function, just use

Sometimes writing an OnClick doesn't work. Try this instead.
In the body of the page write this
<BODY onKeyPress="KeyPress()">

The function KeyPress() should look like this. This will disable the enter key on that page.
function KeyPress()
if (window.event.keyCode == 13)
window.event.keyCode =0;

javascrtipt no enter disable enter key force submit

Back To Top
© 1998 - 2024
Version 7.21 | Advertise on this site