Sunday Quickie - Bookmarklet to Fix Forms that Disable autocomplete

This post is more than 2 years old.

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.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by David Levin posted on 3/23/2014 at 8:35 PM

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. :)

Comment 2 by Raymond Camden posted on 3/23/2014 at 9:17 PM

They are even more annoying on mobile. :(

Comment 3 by Scott Busche posted on 3/24/2014 at 1:38 AM

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.

Comment 4 by WebManWalking posted on 3/30/2014 at 9: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.

Comment 5 by Raymond Camden posted on 3/30/2014 at 10:20 PM

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...