Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autocomplete off vs false?

Recently I have come across an issue where I wanted to disable auto-complete in all browsers.

Chrome has a new feature in settings where you can add a card number. And the requirement was to also disable that.

What worked in all browsers was to do this autocomplete=false at form level.

But this is not compliant with w3 rules, where they enforce to have autocomplete=off|on.

Can someone please explain to me why false works in all browsers?

even ie8, all firefox, safari etc., but it is not compliant.

like image 287
Cross2004 Avatar asked May 05 '15 12:05

Cross2004


People also ask

What does autocomplete off mean?

The autocomplete attribute specifies whether a form should have autocomplete on or off. When autocomplete is on, the browser automatically complete values based on values that the user has entered before. Tip: It is possible to have autocomplete "on" for the form, and "off" for specific input fields, or vice versa.

How do you make an autocomplete false?

Add autocomplete="off" onto the <form> element to disable autocomplete for the entire form. Add autocomplete="off" for a specific <input> element of the form.

Why is autocomplete off?

Setting autocomplete="off" on fields has two effects: It tells the browser not to save data inputted by the user for later autocompletion on similar forms, though heuristics for complying vary by browser. It stops the browser from caching form data in the session history.

Why do browsers ignore autocomplete off?

Chrome respects autocomplete=off only when there is at least one other input element in the form with any other autocomplete value. This will not work with password fields--those are handled very differently in Chrome.


Video Answer


1 Answers

You are right. Setting the autocomplete attribute to "off" does not disable Chrome autofill in more recent versions of Chrome.

However, you can set autocomplete to anything besides "on" or "off" ("false", "true", "nofill") and it will disable Chrome autofill.

This behavior is probably because the autocomplete attribute expects either an "on" or "off" value and doesn't do anything if you give it something else. So if you give it something other than those values, autofill falls apart/doesn't do anything.

With the current version of Chrome it has been found that setting the autocomplete attribute to "off" actually works now.

Also, I have found that this only works if you set the autocomplete attribute in each <input> tag of the form.

There has been a response to this ambiguity in the Chromium bug listings here.

Disclaimer: This was found to be true in Chrome version 47.0.2526.106 (64-bit)

like image 151
camiblanch Avatar answered Sep 19 '22 16:09

camiblanch