Focus next input once reaching maxlength value

Focus next input once reaching maxlength value

by Suryar Praveen

HTML

a: <input type="text" maxlength="5" />
b: <input type="text" maxlength="3" />
c: <input type="text" maxlength="5" />
d: <input type="text" maxlength="3" />
e: <input type="text" maxlength="6" />
f: <input type="text" maxlength="10" />
g: <input type="text" maxlength="7" />

JavaScript

$(document).ready(function(){
    $('input').on("input", function(){
        if($(this).val().length==$(this).attr("maxlength")){
            $(this).next().focus();
        }
    });
});