I'm auto focusing the first input field of my Sign up and Log in form before the page is displayed, but I'm not sure what to do as far as auto focusing erroneous fields after validation.

I have a couple of options in mind when it comes to multiple erroneous fields at once:

  1. Auto focus the first erroneous field input and;

    • select the entire field content if any or;

    • put the text cursor at the end.

  2. No auto focus.

And for scenarios with only one erroneous field:

  1. Auto focus the erroneous field and;

    • select the entire field content if any or;

    • put the text cursor at the end.

  2. No auto focus.

Just to be clear, I'm not forcing users to start with the auto focussed field.

  • A number of interesting thoughts here. What do you see as the pros and cons of each idea? Are you targeting a specific piece of feedback? Commented Aug 31, 2014 at 23:41
  • 1
    Not a direct answer to the question (and hence a comment), but autofocus on page load is a really bad idea. I'm tired of starting to type where I want to and then have a form switch to where it thinks I should start -- and thus my text is split between two fields. If you must use autofocus on initial load, then make sure that field is the only one which is enabled. Commented Sep 1, 2014 at 9:24
  • @AndrewLeach I've made sure the field is already auto focused before the page is displayed to the user, just to avoid this issue. And to be clear, it's not forcing you to start there. You still have the option to select whichever field you want to start with. Commented Sep 1, 2014 at 9:26

1 Answer 1


In both the cases, I would autofocus the first field and put the cursor at the end.

Autofocusing a field gives the users an indication and a starting point to quickly begin correcting their errors while at the same time it doesn't force them to start with that specific field. It also affords you the freedom to provide some more details about the error specific to that field without cluttering the rest of the UI.

Selecting all the text may have unintended effects for somebody who doesn't realize that pressing most keys (certainly A-Z and space) would remove all that they have already entered. That might be even more drastic when it's a textarea with several paragraphs already written.

Thus, to me, it makes more sense to put the cursor at the end. It makes it one more step to delete the text and start over, but the other cases—correcting the error, adding more, or removing something from the already entered text—become just a bit easier.

Doing the same thing in both cases is also consistent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.