happybuddha
happybuddha

Reputation: 1358

How to avoid focus on input box after page load

This is the scenario on a page heavy with flash (graphics) and a form like this :

  <form>
    Username: <input type="text" name="userName">
    Password: <input type="password" name="password">
  </form>

When this page loads, these input boxes appear before all the graphics do. In case when the user doesn't wait for the graphics to load and types in the username and is halfway through typing in password, the graphics load and the focus is set to the username field - making the remaining part of the password to be typed in the username field. There is no javascript interfering with these two fields. How can I avoid this ?

Upvotes: 0

Views: 3576

Answers (1)

Raunak Kathuria
Raunak Kathuria

Reputation: 3225

Try this,

Username: <input id="username" type="text" name="userName">
Password: <input id="password" type="password" name="password">

$(function () {
   $('#username,#password').blur();
});

blur function prevent auto focus on input elements. Make sure no other function is setting the focus on fields

Upvotes: 3

Related Questions