views:

969

answers:

6

You know how browsers autocomplete text boxes? Apparently this confuses users. They see it as a short list with only limited options.

Does anyone know how to disable autocomplete?

A: 

Don't use common names/ids for INPUT tags?

<input type="text" id="year" name="year" ... />

GUIDs are pretty unique, right?

<input type="text" id="1b3d0ea8-3562-4937-a3d3-c91041a17c8b" ... />

That would be fun code to maintain!

Zack Peterson
that wouldnt solve the problem, you would still get a list of the last entered values on the box, unless of course you generated that guid everytime you render the page.
Nuno Furtado
+13  A: 

The proper way to disable autocomplete is like this:

<input type="text" name="foo" autocomplete="off"/>

or

<form autocomplete="off" ... >

MSDN: autocomplete Property

Mozilla: How to Turn Off Form Autocompletion

Applicable browser versions: Netscape 6.2 (Mozilla 0.9.4) or later. IE 5 or later. ...

This form attribute is not part of any web standards but was first introduced in Microsoft's Internet Explorer 5. Netscape introduced it in version 6.2 -- in prior versions, this attribute is ignored. The autocomplete attribute was added at the insistance of banks and card issuers -- but never followed through on to reach standards certification.

Andrew Hare
I know it is also possible to put the attribute autocomplete="off" at the form level. Would it be a good idea?
Nordes
+4  A: 

You can add the autocomplete attribute to input elements, but be aware that it's proprietary for anything less than HTML 5:

<input type="text" id="year" name="year" autocomplete="off" />
John Topley
+13  A: 

There is the attribute autocomplete. It's currently a proprietary attribute (introduced by Microsoft) but on the way to be part of HTML 5:

<input type="text" id="year" name="year" autocomplete="off" ... />

For some background and additional information, see The autocomplete attribute and web documents using XHTML.

Gumbo
Awsome to see that picked up in specification
JoshBerke
+1  A: 

Essentially no, you can't. You can set various attributes that vary from browser to browser (or even browser version to browser version, thanks Microsoft), and you can play games with javascript, but ultimately there's no guarantee that a field won't be autocompleted either accidentally or intentionally in current or future versions of browsers. Your best bet if you're being told to implement this is to apply one or two of the browser specific fixes, and then list those particular versions as the recommended (or required if you want to be mean and alienate customers) browser to use with your site.

Orclev
A: 

Yet another example of developers taking away functionality on the user's own machine. Please developers - DON'T DO THIS. Focusing text boxes on page load is another annoying trait creeping into the mainstream. Annoying. Stop doing this people.

Kolten
There are perfectly valid reasons for disabling autocomplete when you are implementing your own custom drop box of options. In these cases the autocomplete gets in the way of the intended functionality of providing a narrowing list of user-targeted values. I do however agree that disabling autocomplete without providing a better alternative is a bad idea.
Paulo
What's wrong with focusing textboxes on page load? I find it annoying when the textbox isn't focused and I start typing into thin air.
John Topley
Stealing focus has issues with web pages - especially when there is a delay in page load. Typing information into a form, only to have focus stolen from you because an onload='this.setfocus()' is enacted, only serves to infuriate users. This author gives a good account of the problem:http://nyquistrate.com/blog/2008/dec/17/quit-stealing-my-focus/
Kolten