Created
June 9, 2014 18:13
-
-
Save jeremysimmons/00ebcf0065d1b7004fdf to your computer and use it in GitHub Desktop.
prevent enter key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
//Stop Form Submission of Enter Key Press | |
function stopRKey(evt) { | |
var evt = (evt) ? evt : ((event) ? event : null); | |
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); | |
// if the keyCode was Enter, and node that caused event was not a textarea, submit or button, cancel the event | |
if (evt.keyCode == 13 && node.type != "textarea" && node.type != 'submit' && node.type != 'button') { return false; } | |
} | |
document.onkeypress = stopRKey; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment