Skip to content

Instantly share code, notes, and snippets.

@Badgerati
Created April 4, 2013 21:23
Show Gist options
  • Save Badgerati/5314494 to your computer and use it in GitHub Desktop.
Save Badgerati/5314494 to your computer and use it in GitHub Desktop.
This JavaScript will automatically focus another control depending on the length of the current control's content. This should be called in a control's onkeyup event.
function move(current, next, previous, length) {
if (next != null && current.value.length >= length) {
document.getElementById(next).focus();
}
else if (previous != null && current.value.length <= 0) {
document.getElementById(previous).focus();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment