Full version: jsB@nk » Form » Disable 'Enter' Key in Form
URL: https://www.javascriptbank.com/disable-enter-key-in-form.html
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. Moreover, it then advances the cursor to the next field within the form. Very useful.
Full version: jsB@nk » Form » Disable 'Enter' Key in Form
URL: https://www.javascriptbank.com/disable-enter-key-in-form.html
<script type="text/javascript">/************************************************ Disable "Enter" key in Form script- By Nurul Fadilah([email protected])* This notice must stay intact for use* Visit http://www.dynamicdrive.com/ for full source code***********************************************/function handleEnter (field, event) {var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;if (keyCode == 13) {var i;for (i = 0; i < field.form.elements.length; i++)if (field == field.form.elements[i])break;i = (i + 1) % field.form.elements.length;field.form.elements[i].focus();return false;} elsereturn true;} </script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form><input type="text" onkeypress="return handleEnter(this, event)" size="20"><br><input type="text" onkeypress="return handleEnter(this, event)" size="20"><br><textarea rows="1" cols="20">Some text</textarea></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->