Thursday, January 24, 2019

html - How to disable autocomplete for all major browsers



How do you disable Autocomplete in the major browsers for a specific input and/or the complete form.




I found this solution:






However, this does not seem to work in all browsers. I've had problems in firefox for instance.



Edit:




My firefox issue has been resolved. That leaves the following: Can I disable autocomplete on a form or do I have to give every input autocomplete="off"


Answer



Autocomplete should work with the following types: text, search, url, tel, email, password, datepickers, range, and color.



But alas, you could try adding autocomplete='off' to your

tag instead of the 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');
});
});

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...