Some times you want to disable the form submission when someone hits the enter key.
Here is how to do it.

[code language="javascript"]
// Ignores the enter key to prevent accidental form submission.
// Usage:
// src: http://jennifermadden.com/javascript/stringEnterKeyDetector.html
// src: http://www.w3schools.com/jsref/jsref_onkeypress.asp
function my_ignore_enter(e) {
var characterCode;

if (window.event) { // IE
characterCode = e.keyCode;
} else if(e.which) { // Netscape/Firefox/Opera
characterCode = e.which;
}

if (characterCode == 13) {
return false;
}

return true;
}
[/code]

Related

Referral Note: When you purchase through an referral link (if any) on our site, we earn a commission.