Make sure to check out this fiddle first: http://jsfiddle.net/7Prys/
I am looking for a way to automatically focus on the next input field when a user enters a value in the previous field. This should happen until the fourth input field. Is there a simple jQuery solution for this? Additionally, I want the previous input field to be focused when the backspace key is pressed.
Below is the HTML code:
<input type="text" maxlength="1" class="small" />
<input type="text" maxlength="1" class="small" />
<input type="text" maxlength="1" class="small" />
<input type="text" maxlength="1" class="small" />
And here is the jQuery code:
$(".small").onchange(function () {
$(this).next().find(".small").focusIn();
});