Focus Form Field on Page Load

by on July 9th, 2007

Some times you want that when the contact form be loaded, its focus should be in the first form field where user will start typing. For that you need to know that form name, the field name to focus and you need to call onload in the body tag of the web page. Let’s try an example:

<body onLoad="frm.name.focus();">

Onload, form field name field will be focused. Here name is the first field value and frm is the form name. This is helpful when you want to give user facility to auto select the field in form instead of load the web page and click in the field to start typing in the form.


Share