ASP. NET jQuery instance 2 (Use carriage return in the form to move down between TextBox)

Source: Internet
Author: User

The following code can achieve this switching effect.

First, let's look at the interface:
Interface code:Copy codeThe Code is as follows: <body>
<Form id = "form1" runat = "server">
<Div align = "center">
<Fieldset style = "width: 400px; height: 200px;">
<Table cellpadding = "3" cellspacing = "3" border = "0">
<Tr>
<Td>
<Asp: Label ID = "lblName" Text = "name:" runat = "server"> </asp: Label>
</Td>
<Td>
<Asp: TextBox ID = "txtName" Width = "200px" runat = "server"> </asp: TextBox>
</Td>
</Tr>
<Tr>
<Td>
<Asp: Label ID = "lblAddress" Text = "Address:" runat = "server"> </asp: Label>
</Td>
<Td>
<Asp: TextBox ID = "txtAddress" Width = "200px" runat = "server"> </asp: TextBox>
</Td>
</Tr>
<Tr>
<Td>
<Asp: Label ID = "lblContact" Text = "contact number:" runat = "server"> </asp: Label>
</Td>
<Td>
<Asp: TextBox ID = "txtContact" Width = "200px" runat = "server"> </asp: TextBox>
</Td>
</Tr>
<Tr>
<Td>
<Asp: Label ID = "lblEmail" Text = "Email:" runat = "server"> </asp: Label>
</Td>
<Td>
<Asp: TextBox ID = "txtEmail" Width = "200px" runat = "server"> </asp: TextBox>
</Td>
</Tr>
<Tr>
<Td>
</Td>
<Td>
<Asp: Button ID = "btnSubmit" Text = "Submit" runat = "server"/>
<Asp: Button ID = "btnReset" Text = "reset" runat = "server"/>
</Td>
</Tr>
</Table>
</Fieldset>
</Div>
</Form>
</Body>

Script code:Copy codeThe Code is as follows: <Title> Recipe2 </title>
<Script src = "Scripts/jquery-1.4.1-vsdoc.js" type = "text/javascript"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("Input: text: first"). focus (); // the TextBox is converted to the <input type = "text"/>
$ ("Input: text"). bind ("keydown", function (e ){
If (e. which = 13) {// obtain the Enter key value
E. preventDefault (); // prevents forms from being submitted by pressing Enter.
Var nextIndex = $ ("input: text"). index (this) + 1;
$ ("Input: text") [nextIndex]. focus ();
}
});
$ ("# <% = BtnReset. ClientID %>"). click (function (){
$ ("Form") [0]. reset ();
});
});
</Script>
</Head>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.