The realization method of using carriage return instead of tab when filling in form _ form effect

Source: Internet
Author: User
The key is TabIndex, the idea is to set a tabindex for each form element, whose value is the value of the tabindex of the previous form element plus one, and the function is to add the current TabIndex value to one when the user presses the ENTER key. The TabIndex values of each form element are then compared to each other, and if they are equal, the focus is moved above the form element.

First, we need to set a onkeyup event in the table monomer:
<form name= "xxx" action= "yyy.asp" method= "POST" onkeyup= "return Changefocus_onkeyup ()" language= "JavaScript" >

Second, set a TabIndex value in each form element, assuming that the form has three elements, we set the TabIndex value as follows:
<input type=text name= "txtname" size= "tabindex=1>"
<input type=checkbox name= "Chksign" tabindex=2>
<textarea name= "Tarcontent" tabindex=3>

Finally, write down the Changefocus function as follows:
function Newinfo_form_onkeyup ()
{
Key=window.event.keycode;
if (key==0xd)//To determine whether to press the ENTER key
{
Curtabindex=event.srcelement.tabindex 1//Add the current TabIndex value to 1
for (N=0;n<newinfo_form.elements.length;n)
{
if (newinfo_form.elements[n].tabindex==curtabindex)//Find the next form element
{
Newinfo_form.elements[n].focus (); Move focus
return true;
}
}
}
}

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.