Sunday Quickie - Bookmarklet to Fix Forms that Disable autocomplete

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 developer advocate looking for his next gig. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

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

Comments