I do not know how to solve this problem:
The user can begin to enter some numerical values ββin the input fields. The cursor moves to the next input field after entering the number. But this does not work, if the user enters too quickly, this means that there is no keyboard between the two numbers.
So, if the user enters "12" - instead of "1" and "2" - there should be a value of "1" in the first input field, a value of "2" in the second input field and focus should be set in the third input field.
<form> <input type="password" maxlength="1" name="pin1" autofocus /> <input type="password" maxlength="1" name="pin2" /> <input type="password" maxlength="1" name="pin3" /> <input type="password" maxlength="1" name="pin4" /> </form> $('form input').on('keydown', function(event) { if (event.shiftKey || event.which <= 47 || event.which >= 58) return false; }).on('keyup', function (event) { if (event.currentTarget.value.length >= 1) $(event.currentTarget).next('input').focus(); });
http://jsfiddle.net/bbeg17r8/
source share