Focus on next input when maxlength is reached

by Raj Shekhar

HTML

a: <input type="text" maxlength="1" />
b: <input type="text" maxlength="1" />
c: <input type="text" maxlength="1" />
d: <input type="text" maxlength="1" />
e: <input type="text" maxlength="1" />
f: <input type="text" maxlength="1" />
g: <input type="text" maxlength="1" />

JavaScript

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