Currently I am creating a page. Some of the input fields have maxlength being defined, for such fields, I would like to make them possible to move focus to the next input when maxlength has reached.
Here I have the following code segment:
$("form input[type=text]").on('input',function () { if($(this).val().length == $(this).attr('maxlength')) { $(this).next("input").focus(); } }); This code works fine in Chrome and Firefox, however, it does not work in IE. Therefore I search for the solution to tackle the issue. Some suggest to use the setTimeout() method to solve the problem. So i modify the code to the following:
setTimeout(function(){ $("form input[type=text]").on('input',function () { if($(this).val().length == $(this).attr('maxlength')) { $(this).next("input").focus(); } }); }, 3000); But it still does not work in my IE environment. In order to solve the issue, I have tried setInterval() too. None of the two helps solving the problem. Therefore I would like to ask how can I achieve my objective. Or the failure is only caused by I have used the setTimeout() method in a wrong way?
oninputevent works in IE9+