Is There a W3C Valid Way to Disable Autocomplete in a HTML Form

Is there a W3C valid way to disable autocomplete in a HTML form?

Here is a good article from the MDC which explains the problems (and solutions) to form autocompletion.
Microsoft has published something similar here, as well.

To be honest, if this is something important to your users, 'breaking' standards in this way seems appropriate. For example, Amazon uses the 'autocomplete' attribute quite a bit, and it seems to work well.

If you want to remove the warning entirely, you can use JavaScript to apply the attribute to browsers that support it (IE and Firefox are the important browsers) using someForm.setAttribute( "autocomplete", "off" ); someFormElm.setAttribute( "autocomplete", "off" );

Finally, if your site is using HTTPS, IE automatically turns off autocompletion (as do some other browsers, as far as I know).

Update

As this answer still gets quite a few upvotes, I just wanted to point out that in HTML5, you can use the 'autocomplete' attribute on your form element. See the documentation on W3C for it.

Is there a way to disable auto fill for forms on website?

autocomplete="off" should do the trick!

Put this in your <form> tag or in every <input> tag like this:

<form autocomplete="off" />
<!-- OR -->
<input type="text" autocomplete="off" value="Text" />

Is it possible to disable autocomplete?

Use the non-standard autocomplete attribute:

autocomplete="off"

Works in all modern browsers. Will break HTML 4 validation, though. No way around that. Will be valid in HTML 5.

Reference:

  • Mozilla: How to Turn Off Form Autocompletion

  • IE: Using AutoComplete in HTML Forms

Autocomplete off vs false?

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)

Disable autocomplete via CSS

You can use a generated id and name everytime, which is different, so the browser cannot remember this text-field and will fail to suggest some values.

This is at least the cross browser safe alternative, but I would recommend to go with the answer from RobertsonM (autocomplete="off").

Is there a way to prevent browser autofill an input box?

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

That should work.



Related Topics



Leave a reply



Submit