Monday, July 18, 2016

auto focus text box

$(".inputs").keyup(function () {
    if (this.value.length == this.maxLength) {
      var $next = $(this).next('.inputs');
      if ($next.length)
          $(this).next('.inputs').focus();
      else
          $(this).blur();
    }
});
<input class="inputs" type="text" maxlength="4" />
<input class="inputs" type="text" maxlength="4" />
<input class="inputs" type="text" maxlength="4" />
<input class="inputs" type="text" maxlength="4" />
<input class="inputs" type="text" maxlength="4" />
<input class="inputs" type="text" maxlength="4" />