18

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?

Andrew Hare
  • 344,730
  • 71
  • 640
  • 635
Zack Peterson
  • 56,055
  • 78
  • 209
  • 280
  • Really? It confuses them? What era are the from? The bronze age? It's been like that for eons. – Malfist May 21 '09 at 16:36
  • 8
    Rich Cook: "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." – Zack Peterson May 21 '09 at 16:44
  • 2
    eons being the 15 some odd years of the life of the modern WWW? There are ALWAYS new people arriving to computing and the internet :) – patjbs May 21 '09 at 16:45
  • 2
    This is a duplicate... http://stackoverflow.com/questions/2530/how-do-you-disable-browser-autocomplete-on-web-form-field – Paolo Bergantino May 21 '09 at 17:59
  • 1
    And this: http://stackoverflow.com/questions/682439/how-can-i-prevent-firefoxs-autocomplete – Paolo Bergantino May 21 '09 at 18:00
  • 1
    And this: http://stackoverflow.com/questions/582244/is-there-a-w3c-valid-way-to-disable-autocomplete-in-a-html-form/582265 – Paolo Bergantino May 21 '09 at 18:00
  • @Malfist: This is a common issue for me as well especially if other parts of the site have auto-complete Ajax controls. – Greg May 21 '09 at 18:04

5 Answers5

34

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.

Zack Peterson
  • 56,055
  • 78
  • 209
  • 280
Andrew Hare
  • 344,730
  • 71
  • 640
  • 635
  • I know it is also possible to put the attribute autocomplete="off" at the form level. Would it be a good idea? – Nordes May 21 '09 at 16:35
18

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
  • 643,351
  • 109
  • 780
  • 844
7

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
  • 113,588
  • 46
  • 195
  • 237
3

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.

John Topley
  • 113,588
  • 46
  • 195
  • 237
Orclev
  • 695
  • 1
  • 6
  • 16
1

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
  • 56,055
  • 78
  • 209
  • 280
  • 4
    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 May 21 '09 at 16:30