XForms/Setting Initial Cursor

Motivation
When a form loads you want to set the initial cursor position so the user's first keystrokes are entered into the first field. This prevents the user from having to select the first field on a form with the mouse. Although some people consider this "polish" it is the hallmark of a conscientious developer.

Method
To perform this task you must do two things. First you need to give the control you want to receive the first keystroke event an id attribute. For example:

The next step is to use the xforms-ready event to set the focus to this field using the setfocus element.

These initial actions are usually placed at the end of the model in the html header but before the body.

Link to XForms Application
Load XForms Application

Source Code


    Initial Cursor Positioning  Element One: 