Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web Development
Expertise: Beginner
May 26, 1999

Make a Cursor Appear in First Form Field

Question:
When designing a form, like a login page, how do I make the cursor automatically sit in the first form field? For example, I ask for an admin number and a pin number. First, however, the user must click in the admin number input field box before they can type their response. I would like the default to be automatically in the input box.

Answer:
You can use client-side script to control which field has focus. Use the window_onload event to run script that sets focus to the textbox that you want. The JavaScript in this page will do the trick:




	

	

	

	
	




    
    


DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date