Cursor Focus
CSGNetwork FREE Source Code, Javascript Source, and Code Snippets!

 
CSGNetwork
Snippets
Calculators
Home
Back



Right click this window and select "view source" in order to copy the source for this script.

Form Focus

Here's a helpful little script for anyone who has ever made a form and wants to have the cursor pop into their first field when the page is loaded. The visitor can start typing straight away, without moving the mouse.

Note that if you have much introductory content before the form, meaning that the first field would not normally appear in the window without scrolling, the browser will automatically scroll down to show the field, so it may not be suitable in all cases.

Please enter a number:

All you need do is put
onLoad="self.focus();document.Form_Name.Field_Name.focus()" inside the tag, where "Form_Name" is the name of your form, and "Field_Name" is the name of the first field.