<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load()
{
StringBuilder sb = new StringBuilder();
sb.Append("var box1 = document.getElementById('");
sb.Append(TextBox1.ClientID);
sb.Append("');");
sb.Append("var box2 = document.getElementById('");
sb.Append(TextBox2.ClientID);
sb.Append("');");
sb.Append("if (box1 != null && box1.value.length == 5 && box2 != null)");
sb.Append("{");
sb.Append("box2.focus();");
sb.Append("}");
TextBox1.Attributes.Add("onkeyup", sb.ToString());
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" />
<asp:TextBox ID="TextBox2" runat="server" />
</div>
</form>
</body>
</html>
Bookmarks