jQuery – focus on next input

HTML

<asp:TextBox ID="txtPostalCodeFSA" runat="server" CssClass="postalCode" MaxLength="3" />
<asp:TextBox ID="txtPostalCodeLDU" runat="server" CssClass="postalCode" MaxLength="3" />

jQuery

$(document).ready(function () {
	$('.postalCode').keyup(function () {
		if (this.value.length == this.maxLength) {
			$(this).next('.postalCode').focus();
		}
	});
});

Source: Stack Overflow
Working example: jsFiddle

Leave a Reply

Your email address will not be published. Required fields are marked *