Created
March 23, 2011 22:59
-
-
Save rajraj/884217 to your computer and use it in GitHub Desktop.
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(){ | |
// Collect all text boxes | |
$textboxes = $(":text"); | |
// call checkForEnter function when a key is pressed | |
$textboxes.keydown(checkForEnter); | |
// This function checks if the Enter key is pressed | |
// If yes then moves the cursor to the next box | |
function checkForEnter(event) { | |
if (event.keyCode == 13) { | |
numCurrentTextbox = $textboxes.index(this); | |
if (numCurrentTextbox + 1 != null) { | |
event.preventDefault(); | |
nextTextbox = $textboxes[numCurrentTextbox + 1]; | |
nextTextbox.select(); | |
return false; | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment