Autotab input with javascript -
i have 3 inputs need tab next when max length reached. these 3 inputs come values , when user change value of first input focus on next , on.
my problem since second input has length jumps third input. if use input values don't this.
the source of problem if typing fast first keyup event fired after second type , fires on second input.
i've written jsfiddle problem , function wire auto focus change.
function wireautotab(currentelement, nextelement) { currentelement.keyup(function (e) { //retrieve key pressed. var keyid = (window.event) ? event.keycode : e.keycode; var fieldlength = currentelement.attr('maxlength'); //if user has filled textbox given length , //the user pressed number or letter, move //cursor next element in tab sequence. if (currentelement.val().length >= fieldlength && ((keyid >= 48 && keyid <= 90) || (keyid >= 96 && keyid <= 105))) nextelement.focus(); }); }
is there other event can use prevent this? behavior want if second input has value, stops on it.
Comments
Post a Comment