Auto Tab Transfer from one textbox to another textbox using Javascript
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js" charset="utf-8">
</script>
<script type="text/javascript">
$(document).ready(function () {
$("#<%=TextBox1.ClientID %>").keyup(
function changefocus() {
if ($("#<%=TextBox1.ClientID %>").val().length >= $("#<%=TextBox1.ClientID %>").attr('maxlength'))
$("#<%=TextBox2.ClientID %>").focus();
});
$("#<%=TextBox2.ClientID %>").keyup(
function changefocus() {
if ($("#<%=TextBox2.ClientID %>").val().length >= $("#<%=TextBox2.ClientID %>").attr('maxlength'))
$("#<%=TextBox3.ClientID %>").focus();
});
$("#<%=TextBox3.ClientID %>").keyup(
function changefocus() {
if ($("#<%=TextBox3.ClientID %>").val().length >= $("#<%=TextBox3.ClientID %>").attr('maxlength'))
$("#<%=TextBox4.ClientID %>").focus();
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server" MaxLength="3"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" MaxLength="3"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" MaxLength="4"></asp:TextBox>
<asp:TextBox ID="TextBox4" runat="server" MaxLength="4"></asp:TextBox>
</form>
</body>
</html>
No comments:
Post a Comment