JSFiddle - React, Tailwind, and code Playground
HTML
<form id="aspnet_form" runat="server">
<input type="text" maxlength="2" id="first" />
<input type="text" maxlength="2" id="second" value="12" />
<input type="text" maxlength="2" id="third" value="12" />
</form>
JavaScript
function WireAutoTab(CurrentElement, NextElement) {
CurrentElement.keyup(function(e) {
//Retrieve which key was pressed.
var KeyID = (window.event) ? event.keyCode : e.keyCode;
var FieldLength = CurrentElement.attr('maxlength');
//If the user has filled the textbox to the given length and
//the user just pressed a number or letter, then move the
//cursor to the next element in the tab sequence.
if (CurrentElement.val().length >= FieldLength
&& ((KeyID >= 48 && KeyID <= 90) ||
(KeyID >= 96 && KeyID <= 105)))
NextElement.focus();
});
}
(function( $ ) {
$.fn.autoTab = function() {
var currentElement = null;
$(this).each(function() {
if(currentElement != null) {
WireAutoTab(currentElement, $(this));
}
currentElement = $(this);
});
}
$('input').autoTab();
})($);