How do you disable autocomplete
in the major browsers for a specific input
(or form field
)?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
Use a non-standard name and id for the fields, so rather than "name" have "name_". Browsers will then not see it as being the name field. The best part about it is that you can do this to some but not all fields and it will autocomplete some but not all fields.
On a related or actually, on the completely opposite note -
I can't believe this is still an issue so long after it's been reported. The above solutions didn't work for me, as safari seemed to know when the element was not displayed or off-screen, however the following did work for me:
Hope that's useful for somebody!
Firefox 30 ignores
autocomplete="off"
for passwords, opting to prompt the user instead whether the password should be stored on the client. Note the following commentary from May 5, 2014:According to Mozilla developer documentation the form element attribute
autocomplete
prevents form data from being cached in older browsers.Most of the major browsers and password managers (correctly, IMHO) now ignore
autocomplete=off
.Why? Many banks and other "high security" websites added
autocomplete=off
to their login pages "for security purposes" but this actually decreases security since it causes people to change the passwords on these high-security sites to be easy to remember (and thus crack) since autocomplete was broken.Long ago most password managers started ignoring
autocomplete=off
, and now the browsers are starting to do the same for username/password inputs only.Unfortunately, bugs in the autocomplete implementations insert username and/or password info into inappropriate form fields, causing form validation errors, or worse yet, accidentally inserting usernames into fields that were intentionally left blank by the user.
What's a web developer to do?
Chrome 34, unfortunately, will try to autofill fields with user/pass whenever it sees a password field. This is quite a bad bug that hopefully, they will change the Safari behavior. However, adding this to the top of your form seems to disable the password autofill:
I haven't yet investigated IE or Firefox thoroughly but will be happy to update the answer if others have info in the comments.
This works for me.
We can also use this strategy in other controls like text, select etc