Let’s create a simple form with two fields called username and password. The goal is to bring the cursor to the “username” field when the page is loaded. First, we assign an “id” and “name” to the form. Let’s call it “login” for lack of a better name. Next, we need to assign an “id” and “tabindex” to each input. We will use “id=’username'” and “tabindex=’1′” for the first input, and “id=’password'” and “tabindex=’2′” to the second input. See the example below.
<form id="login" name="login" method="post" action=""> <label for="username">Username: </label> <input id="username" tabindex="1" type="text" name="username"/><br/> <label for="password">Password: </label> <input id="password" tabindex="2" type="password" name="password" /><br/> <input type="submit" name="submit"/> </form>