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
Transparent Half Circle Cut Out of a Div
Curve Bottom Side of the Div to the Inside With Css
Multiple Lines of Input in ≪Input Type="Text" /≫
How to Avoid Joining All Text from Nodes When Scraping
Center a Div Horizontally and Vertically
Scraping Data from Website Using Vba
Default Select Option as Blank
Css Cut Out Circle from a Rectangular Shape
Ie9 Float With Overflow:Hidden and Table Width 100% Not Displaying Properly
Is Either Get or Post More Secure Than the Other
Centered Elements Inside a Flex Container Are Growing and Overflowing Beyond Top
How to Use Jsf+Facelets With HTML 4/5
Inputting a Default Image in Case the Src Attribute of an HTML ≪Img≫ Is Not Valid
Implement an Input With a Mask
Is There a Limit to the Length of HTML Attributes
What Does Appending "V=1" to CSS and JavaScript Urls in Link and Script Tags Do