Last active
December 13, 2015 18:39
-
-
Save mikehibm/4957085 to your computer and use it in GitHub Desktop.
Prevent submiting form and move focus to next input field when Enter key is pressed.
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
$(function(){ | |
var elements = "input[type=text]"; | |
$(elements).keypress(function(e) { | |
var c = e.which ? e.which : e.keyCode; | |
if (c == 13) { | |
var index = $(elements).index(this); | |
$(elements + ":gt(" + index + "):first").focus(); | |
e.preventDefault(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment