devxlogo

Make a Cursor Appear in First Form Field

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-admin

Share the Post: