Skip to content

Instantly share code, notes, and snippets.

@anselmobattisti
Created December 11, 2009 19:52
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 anselmobattisti/254462 to your computer and use it in GitHub Desktop.
Save anselmobattisti/254462 to your computer and use it in GitHub Desktop.
textboxes = $("input, select, textarea");
if ($.browser.mozilla) {
$(textboxes).keypress (checkForEnter);
} else {
$(textboxes).keydown (checkForEnter);
}
function checkForEnter (event) {
console.log(this);
if (event.keyCode == 13) {
currentBoxNumber = textboxes.index(this);
if (textboxes[currentBoxNumber + 1] != null) {
nextBox = textboxes[currentBoxNumber + 1]
nextBox.focus();
event.preventDefault();
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment