Is autocomplete=off compatible with all modern browsers?
Be aware that all major browsers are moving towards ignoring the attribute for password fields.
I can only offer anecdotal evidence, but I've yet to come across a browser that fails to respect autocomplete="off"
, this experience covers:
- Firefox 1.5+ (Windows and Ubuntu)
- Opera 6+ (Windows and Ubuntu)
- Chrome v2+ (Windows and Ubuntu)
- Epiphany 0.8 (ish) (Ubuntu)
- Midori (I can't remember which version)
- Safari v1+ (Windows)
- IE 4 - 8, Windows.
I'm aware that Greasemonkey scripts, and presumably other user-scripts, can disable the autocomplete
setting.
There's a couple of articles I found that might be useful to you:
- How to turn off form auto-completion
- Using auto-complete in html forms
How to disable autocomplete for all major browsers
Autocomplete
should work with the following <input>
types: text, search, url, tel, email, password, datepickers, range, and color.
But alas, you could try adding autocomplete='off'
to your <form>
tag instead of the <input>
tag, unless there's something preventing you from doing that.
If that doesn't work, you could also use JavaScript:
if (document.getElementsByTagName) {
var inputElements = document.getElementsByTagName(“input”);
for (i=0; inputElements[i]; i++) {
if (inputElements[i].className && (inputElements[i].className.indexOf(“disableAutoComplete”) != -1)) {
inputElements[i].setAttribute(“autocomplete”,”off”);
}
}
}
Or in jQuery:
$(document).ready(function(){
$(':input').live('focus',function(){
$(this).attr('autocomplete', 'off');
});
});
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.
which web browsers (and which versions) implement the autocomplete=off feature?
According to MDN: input element the autocomplete
attribute is supported from these browser versions:
Desktop:
- Chrome 17.0
- Firefox 4.0
- Internet Explorer 5
- Opera 9.6
- Safari 5.2
Mobile:
- Android : unknown
- Firefox Mobile 4.0
- IE Mobile : all
- Opera Mobile : all
- Safari Mobile : all
autocomplete= off not working in chrome
It appears that Chrome now ignores autocomplete="off" unless it is on the <form autocomplete="off">
tag since v34.
you can't cheat by create an hidden input over. Auto complete feature will get the first input text to fill data.
Method 1:
<form id="" method="post" action="" autocomplete="off">
<input type="text" style="display:none" />
<input type="password" style="display:none">
<asp:textbox autocomplete="off">
</form>
So put this before your textbox.
<input type="text" style="display:none" />
Method 2:
Change
autocomplete="off"
to
autocomplete="false"
Method 3:
Browser autofill in by readonly-mode.
<input type="password" readonly onfocus="this.removeAttribute('readonly');"/>
Method 4:
For username password combinations. Chrome heuristics looks for the pattern.
<input type="text" onfocus="this.type='password'">
Method 5:
jQuery
if ($.browser.webkit) {
$('input[name="password"]').attr('autocomplete', 'off');
$('input[name="email"]').attr('autocomplete', 'off');
}
Related Topics
Do I Use ≪Img≫, ≪Object≫, or ≪Embed≫ For Svg Files
Is It Necessary to Write Head, Body and HTML Tags
Equal Width Flex Items Even After They Wrap
Detect When an Html5 Video Finishes
How to Align Checkboxes and Their Labels Consistently Cross-Browsers
What Are All the Valid Self-Closing Elements in Xhtml (As Implemented by the Major Browsers)
Why Does My Image Have Space Underneath
How to Vertically Align Text Inside a Flexbox
Href Image Link Download on Click
Last Margin/Padding Collapsing in Flexbox/Grid Layout
Change Color of Png Image Via Css
Border Length Smaller Than Div Width