I have to automatic focus next input element when a number has been entered.
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)'>" +
And in my javascript I have:
$('.inp-num').on('keyup', function() {
if ($(this).val()) {
$(this).next().focus();
}
});
This actually works fine, thing is when Im trying to use it on my cellphone, it keeps staying at the same input, doens't go to the next one. I really need help on this.
Thanks!