Friday, May 20, 2011

Make Enter Button As Tab Key

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!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>Untitled Page</title>

    <script src="script/JScript.js" type="text/javascript"></script>

    <script type="text/javascript">
        function keypressed(e) {
            var intKey = (window.Event) ? e.keyCode:e.which;

            if (intKey == 13) {
                document.getElementById('<%=text2.ClientID %>').focus();
                return false;
            }

        }

        function keypressed2(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text3.ClientID %>').focus();
                return false;

            }
        }

        function keypressed3(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text4.ClientID %>').focus();
                return false;

            }
        }

        function keypressed4(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text5.ClientID %>').focus();
                return false;

            }
        }

        function keypressed5(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text6.ClientID %>').focus();
                return false;

            }
        }

        function keypressed6(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text7.ClientID %>').focus();
                return false;

            }
        }

        function keypressed7(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text8.ClientID %>').focus();
                return false;

            }
        }

        function keypressed8(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text9.ClientID %>').focus();
                return false;

            }
        }

        function keypressed9(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=text10.ClientID %>').focus();
                return false;

            }
        }

        function keypressed10(e) {
            var intKey = (window.Event) ? e.keyCode : e.which;
            if (intKey == 13) {

                document.getElementById('<%=DropDownList1.ClientID %>').focus();
                return false;

            }
        }

        function keypressed11(e) {
            var intKey = (window.Event) ? e.keyCode:e.which;
            if (intKey == 13) {

                document.getElementById('<%=Button1.ClientID %>').focus();
                return false;

            }
        }

        function Validation1() {
            if (document.getElementById('<%=DropDownList1.ClientID %>').value == "Select::") {
                alert('select DropDownList');
                       document.getElementById('<%=Button1.ClientID %>').focus();
                return false;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox  onkeypress="return keypressed(event)"  id="text1" runat="server" Width="200px" ></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed2(event)" id="text2" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed3(event)" id="text3" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed4(event)" id="text4" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed5(event)" id="text5" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed6(event)" id="text6" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed7(event)" id="text7" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed8(event)" id="text8" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed9(event)" id="text9" runat="server" Width="200px"></asp:TextBox><br/>
    <asp:TextBox onkeypress="return keypressed10(event)" id="text10" runat="server" Width="200px"></asp:TextBox><br/>
     <asp:DropDownList ID="DropDownList1" runat="server" onkeypress="return keypressed11(event)">
        <asp:ListItem>Select::</asp:ListItem>
        </asp:DropDownList><br/>
     <asp:Button ID="Button1" runat="server" OnClientClick="return Validation1();" Text="Button" OnClick="Button1_Click" />
<asp:Label id="lblMsg" runat="server" forecolor="Red" text="* Username must be alphanumeric with no special characters"></asp:Label>
    </div>
    </form>
</body>
</html>

0 comments:

Post a Comment