Reputation: 365
I have a website where I have some functionality needed:
No autocompletion, suggestions or saving on my site:
Prevent "spilling" to other sites:
Up until now I have accomplished this by using autocomplete = "off" on all forms. Based on this link from Mozilla this should originally have the effect of solving all the issues above, but some browsers are now starting to ignore the autocomplete attribute. The article referred to above states that the trick is to assign an invalid value to the attribute, such as autcomplete = "nope"
My questions are:
Q1: Will the solution of using autocomplete = "nope" also prevent caching/saving the data?
Q2: Are there better solutions to accomplish my criteria for best cross-browser compatibility? (I have searched, but not found anything that gives me Clear answers).
Upvotes: 2
Views: 672
Reputation: 2290
The best solution is as you mentioned to put an invalid value as shown here.
In some cases, the browser will continue suggesting autocompletion values even if the autocomplete attribute is set to off. This unexpected behavior can be quite puzzling for developers. The trick to really enforcing non-autocompletion is to assign an invalid value to the attribute, for example:
autocomplete="nope"
Since this value is not a valid one for the autocomplete attribute, the browser has no way to match it, and stops trying to autocomplete the field.
Your data or cache wouldn't be affected by this and depending on what your form is built in, the data would only be saved via the form
action or function
handlers on the inputs
.
Alternatively, I have found autocomplete= 'new-password'
on the input to be reliable, however the above example on the form
wrapper requires much less work than adding to every input
Upvotes: 1