I need my input fields to automatically focus on the next element after a number is entered.
Here's my HTML:
"<input id='num-1' class='inp-num' data-pos='0' type='text' maxlength='1' name='one' onkeypress='isInputNumber(event)' autofocus='autofocus'/>" +
"<input id='num-2' class='inp-num' data-pos='1' type='text' maxlength='1' name='two' onkeypress='isInputNumber(event)'>" +
"<input id='num-3' class='inp-num' data-pos='2' type='text' maxlength='1' name='three' onkeypress='isInputNumber(event)'>" +
"<input id='num-4' class='inp-num' data-pos='3' type='text' maxlength='1' name='four' onkeypress='isInputNumber(event)'>" +
In my JavaScript, I have the following:
$('.inp-num').on('keyup', function() {
if ($(this).val()) {
$(this).next().focus();
}
});
This code works as expected, but when I try it on my cellphone, it doesn't move to the next input field. Can someone help me with this issue?
Thank you!