Make a Cursor Appear in First Form Field

Make a Cursor Appear in First Form Field

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.

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:

See also  How College Students Can Shape the Future of Tech Responsibility

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist