Edit on February 14, 2017: I modified the code to handle autocomplete being set in input fields as well.
I don't know about you, but when I see a form that has disabled autocomplete, I get pretty upset:
I understand the logic behind doing so on certain secure forms, but when I ran into this a few minutes ago for a freaking survey I wanted to punch my screen. (Ok, maybe I need to take a deep breath and relax too. ;)
For the heck of it, I wrote a quick bookmarklet to fix this problem. A bookmarklet is simply a set of JavaScript code in a bookmark. I've added this bookmark to my main toolbar so it is one click away. Just add the following:
javascript:forms = document.querySelectorAll("form, input");for(var i=0;i<forms.length;i++) { forms[i].removeAttribute("autocomplete"); }
I'm sure this could be written better (maybe instead of always removing the attribute it could always enable it), but on my limited testing (the form that ticked me off) it worked perfectly.
Archived Comments
What a great idea! I share your frustration when it comes to some sites disabling auto complete on their forms. This tip should save monitors everywhere from getting punched! ;)
It also got me thinking that maybe there would be a similar way to also automatically disable commonly used JavaScript on many sites which creates those annoying advertisement popups (via thickbox, lightbox, colorbox, etc...). Those things are especially annoying when browsing on a mobile device and you can't find the little "x" to close the ad.
Thanks for the tip and the inspiration. :)
They are even more annoying on mobile. :(
I use the Chrome extension Autocomplete On (https://chrome.google.com/w... which does it automatically, something similar probably exists for Firefox. I wish Chrome extensions worked on mobile though.
Just curious. Why not document.forms instead of querySelectorAll? It's an already-built property, doesn't require DOM traversal in the method and has been supported since JavaScript 1.0.
Don't get me wrong. I really like this post. Too many devs forget that the user owns the browser and trespass on the user's territory / decision-making prerogatives.
Honestly, I just like querySelector. :) document.forms felt like a hack to me, but it is to spec: http://www.w3.org/TR/DOM-Le...