Disable "Enter" Key in Form script
Description: Is the user pressing the "Enter" key in the middle of your form causing inadvertent and incomplete form submissions? This script disable the "Enter" key when pressed inside chosen fields of your choice (most commonly <input type="text"> fields). Moreover, it then advances the cursor to the next field within the form. Very useful.
Demo: Try filling out the text fields below and pressing "Enter." Notice how instead of submitting the form, the cursor is instead advanced to the next field:
Step 1: Add the below script to the <HEAD> section of your page:
Step 2: Now, inside the form fields you wish to disable the "Enter" key and advance focus to the next field instead, simply add the below "onkeypress" event handler inside its tag as follows:
<form> <input type="text" onkeypress="return handleEnter(this, event)"><br> <input type="text" onkeypress="return handleEnter(this, event)"><br> <textarea>Some text</textarea> </form>