SO - 29293167

by KelseyW

HTML

<div id="first-section">
    <fieldset>
        <legend>First Section</legend>
        <input type="number" placeholder="000" id="input1" min="0" max="255" autofocus maxlength="3" required />
    </fieldset>
</div>
<div id="second-section">
    <fieldset>
        <legend>Second Section</legend>
        <input type="number" placeholder="000" id="input2" autofocus min="0" max="255" maxlength="3" required />
    </fieldset>
</div>

JavaScript

$(':input').keyup(function (e) {
    if ($(this).val().length == $(this).attr('maxlength')) {
        $(this).closest('div').next().find(':input').first().focus();
    }
})