Created
January 25, 2014 13:55
-
-
Save jsven69gist/8616727 to your computer and use it in GitHub Desktop.
jQuery: Disable <enter> in input elements within "#Form" with optional focusshift to next input element
This file contains hidden or 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
// Disables enter key on all input fields on #Form. Can also shift focus to next input field | |
$('#Form').on('keypress', 'input', function(event) { | |
if (event.keyCode == 13) { | |
event.preventDefault(); | |
if ('You want enter2tab') { | |
$(this).next('input').focus(); | |
} else { // Just disable enter key | |
return false; | |
} | |
} else { | |
return true; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment