[jQuery] Auto-focus next box
Hi all,
I've got five text boxes representing the four (or five for longer ones)
parts of a credit card number. They all follow one another in the DOM
without any other elements in between.
What I want to do is when 4 digits have been typed into one box,
auto-focus the next one. I could do this:
$("#box1").keyup(function() {
// IF LENGTH IS 4 FOCUS BOX2
});
$("#box2").keyup(function() {
// IF LENGTH IS 4 FOCUS BOX3
});
$("#box3").keyup(function() {
// IF LENGTH IS 4 FOCUS BOX4
});
$("#box4").keyup(function() {
// IF LENGTH IS 4 FOCUS BOX5
});
But there has to be a shorter way, right?
Regards,
Michael Price