giving form input bos focus

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

How do you give an input box in a form focus when the page loads so that you
can just start typing without having to click in the box first.

Re: giving form input bos focus

new Karoo said...

Quoted text here. Click to load it

this is a bad thing to do. don't bother implementing it. the visitor
may not wait for the page to finish loading before they start filling
out the form so the focus will jump and they may not notice or they
may not all fill the form out in the order you would expect.

i had a host once that did it for the login page. after filling in the
username and half way through the password all of a sudden the focus
would jump back to the username and i would have to start again. it
was very bloody annoying.

brucie a. blackford. 25/July/2003 07:32:58 am kilo. /

Re: giving form input bos focus

Quoted text here. Click to load it

I am taking the opportunity to jump in and propose an alternative to the
OT's suggestion. To me it is clear that he wants the visitor to be able
to focus on the field as quickly as possible.

I suggest putting a TABINDEX attribute on the INPUT, with a value that
enables the user to quickly tab to the field, surpassing any links or
form controls that may be in the way.

For instance,

<input type="text" name="search" tabindex="1">

Another (additional) idea is to set an ACCESSKEY on the field. However,
using accesskeys is not a popular thing, since it is heard of that it
can interfere with existing keyboard shortcuts in some browsers. Yet, as
an illustration,

<input type="text" name="search" tabindex="1" accesskey="s">

To make this key combination visible to the user would be good. This
could be a way of doing that.

<label>Search: (<kbd>s</kbd>) <input type="text" name="search"
tabindex="1" accesskey="s"></label>

Using accesskeys differs between OS's and browsers, but generally a
modifier key is used in combination with the specified key. ALT-s,
OPTION-s or CTRL-s. See which one applies.

kristiaan@xs4all.netherlands (nl)
"We called him Tortoise because he taught us" said the Mock Turtle.

Re: giving form input bos focus

Jacqui or maybePete said...

Quoted text here. Click to load it

focus moves if i don't start typing straight away when the page is
cached. if i'm fast i can click the field i want and type before focus
moves. i still don't see the point of using it in any case. whats so
wrong with letting the visitor fill the form out how they want instead
of second guessing what the visitor wants?

brucie a. blackford. 25/July/2003 07:24:20 pm kilo. /

Re: giving form input bos focus

Quoted text here. Click to load it

Search engine interfaces are rather special. When the _only_ content of
a page is a search form, then a case can be made in favor of automated
initial focus. Even this has some problems though, as Brucie mentioned.
But the real problems begin when people imitate the idea on their own
pages where a form is just a minor ingredient. Automatic initial
focusing implies that tabbing does not start at a reasonable position.

Yucca, /
Pages about Web authoring:

Site Timeline