Skip to content

Instantly share code, notes, and snippets.

@jsven69gist
Created January 25, 2014 13:55
Show Gist options
  • Save jsven69gist/8616727 to your computer and use it in GitHub Desktop.
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
// 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