Disable Enter Key Within Forms

 

Disable Enter Key Within Forms

If you would like to disable enter key within forms, this code will assist you. If you have an HTML form on your web page, many times your visitors may hit the ‘Enter’ key on their keyboard, instead of the ‘Tab’ key, thinking it will advance them to the next form field. However, the ‘Enter’ key will actually submit the form. This will cause you to receive incomplete form submissions.

To avoid this problem, you can use a piece of JavaScript within your HTML code that will disable the ‘Enter’ button within your forms until it is completely filled out.

 

Place the following JavaScript code within your web page HTML between your HEAD tags:

<script language=javascript type=text/javascript>
<!– Script courtesy of http://www.web-source.net – Your Guide to Professional Website Design and Development
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type==”text”)) {return false;}
}

document.onkeypress = stopRKey;
–>
</script>

This concludes the disable enter key within forms section.
 

 

 

 
Visit the following pages for a wealth of copy and paste codes and tips:

HTML Tips
Copy and paste special effect HTML codes for your web page.

HTML Codes
An HTML codes chart you can use to copy and paste codes into your web page.

HTML Color Codes
An HTML color codes chart you can use to copy and paste color codes into your web page.

JavaScript Codes
Copy and paste special effect JavaScript codes for your web page.

Web Design Tips
Tips, tricks, and special effect codes for your web page.

HTML Tags
A list of HTML tags.

HTML 5 Tags
A list of the latest HTML tags to be developed.

ASCII Codes
Special text characters and code for your web page.

Script code provided by: John Nitkowski