Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save thilak-rao/7692169 to your computer and use it in GitHub Desktop.

Select an option

Save thilak-rao/7692169 to your computer and use it in GitHub Desktop.
Once the maximum number of characters has been reached within a defined text fields, the focus is automatically set to the defined target of the element. This is the simplest method. Other jQuery plugins exists, but this is easier.
$("input[type=text]").on('input',function () {
if($(this).val().length == $(this).attr('maxlength')) {
$(this).next("input").focus();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment