◄ Back to BLOG INDEX

A Workaround for Safari's Aggressive Password AutoFill

Published Apr 1, 2014 01:21am

Safari 7 is far too aggresive, virtually ignoring the autocomplete="off" directive added to form and input elements. Its predecessor had a preference that controlled this behavior. Why Apple decided to remove that preference and always AutoFill is beyond me, and became very frustrating when developing web applications that contained password fields. My personal login username and password for the site would override the value in these form fields. I'm okay with having to toggle AutoFill on and off as needed, but this wasn't an acceptable workaround for my clients.

The WorkAround

During one of my sleepless nights, I've come up with an elegant workaround thanks to JavaScript. Instead of having type="password" fields in your form, keep them as normal type="text" inputs, and then use JavaScript to change the type attribute on the fields to "password" in about 250 milliseconds after the page loads. That is just long enough to avoid Safari's AutoFill behavior from kicking in.

Problem solved.

Mac OS XSafari
comments powered by Disqus