Force iOS to Stop Autofilling User/Password Form Fields

To force iOS to stop autofilling saved form data into your form, simply add name=”reg” (short for registration) to your form tag:

<form method=”post” name=”reg”>

 

Background

I ran into a problem on Naming Force where iOS was using saved Login data to autofill a form other than the sign in form. The Edit User page was being filled in by the Login saved data. The real problem was that the wrong fields were being autofilled. For some reason iOS was putting the saved Email address into the Username field after the page loaded. If a user didn’t notice the yellow background on the field they wouldn’t realize that iOS had changed their data and clicking “Save” would save their email address as their Username. Obviously not what they want (and it happened – about 50 times before someone reported it).

I discovered that iOS tries to interpret forms and decide if they should be autofilled. Changing the name of the INPUT field to “xyz” didn’t stop iOS from autofilling either. I even tried the autocomplete=”off” and autocorrect=”off” atrributes to no avail. It turned out that just having a DIV with text of “Username” right before the INPUT field tipped iOS off and allowed this field to be autofilled. Only changing the text of the label stopped the Username fielf from being filled in, but then Paypal Email became the next target of iOS’s autofill.

Fix (Not a Hack)

I tried many things and did a lot of Googling. Finally I came across this blog post that had the not-well-publicized fix. In the post Sean Rucker explains that adding an HTML attribute of “name” with a value of  “reg” to your FORM tag will disable the autofill. And it works!

<form method=”post” name=”reg”>

I had ready tons and tons of forum and blog posts about people suggesting crazy fixes for this (jQuery tricks, hiding form fields, etc) but this is obvious the “right” fix. Strangely, this is only one of two blog posts Sean Rucker has ever made. The blog post almost feels like planted evidence. Or maybe I’ve been reading too many crime novels.