How to set the default input focus on a field in an HTML Web Form

Source: Internet
Author: User

When I create a web-based user interface I tend to is a fanatic about making sure that the first input field on a form get s input focus when the form is first displayed. It always drives me crazy if I go to a Web form this requires text input, but the developer of the page hasn ' t taken the Time to put the default focus in the first field of the form.

So ... after looking around @ some html/jsf/struts/jsp code I ' ve written over the last few years, the following JSF Examp Le shows the most concise-I know of setting default input focus on an HTML form field:

  

In this example I use the

  

Syntax to put the default input focus in the TextField named contact_add:contact_name . When using JSF, this is the name of the JSF ends up applying to my "first name" TextField. In your code just use the name of the your HTML component.

How to set the default input focus on a field in an HTML Web Form

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.