Twitter: raymondcamden

Address: Lafayette, LA, USA

Sunday Quickie - Bookmarklet to "Fix" forms that disable autocomplete

03-23-2014 3,038 views Misc 5 Comments

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");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.


These comments will soon be imported into Disqus. To add a comment, use Disqus above.
  • Commented on 03-23-2014 at 11:35 AM
    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. :)
  • Commented on 03-23-2014 at 12:17 PM
    They are even more annoying on mobile. :(
  • Scott Busche #
    Commented on 03-23-2014 at 4:38 PM
    I use the Chrome extension Autocomplete On ( which does it automatically, something similar probably exists for Firefox. I wish Chrome extensions worked on mobile though.
  • WebManWalking #
    Commented on 03-30-2014 at 12:09 PM
    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.
  • Commented on 03-30-2014 at 1:20 PM
    Honestly, I just like querySelector. :) document.forms felt like a hack to me, but it is to spec: