Skip to content

Instantly share code, notes, and snippets.

@fedir
Created May 15, 2013 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedir/5583689 to your computer and use it in GitHub Desktop.
Save fedir/5583689 to your computer and use it in GitHub Desktop.
Prevent submitting form by hitting enter # ref. http://webcheatsheet.com/javascript/disable_enter_key.php
function stopReturnKey(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 = stopReturnKey;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment