Wednesday, 25 July 2007

Google Autofill - taming its overenthusiasm

Google's autofill is very clever, but sometimes too clever for its own good.

Google are very sketchy on details of how developers can work with the feature, and experimentation indicates that the rules at work are anything but predictable.

I had trouble with a field labelled "Country" where I wanted to set a code using my own country notation (England/Wales/Scotland/Northern Ireland - there seems no standard coding for these, and Google Autofill has no field that is relevant).

Google insisted that it could autofill this field (but got it wrong).

Step 1 - rename the Select field to exclude "Country" : no change.

Step 2 - insert a spurious and empty "span" tag in the middle of the word "Country" in the label field - ie Country

Success. Google no longer reckons it knows about how to fill the field and it remains uncoloured. But it's in no way elegant, and I fear that it may cause problems for some screen reader programs

Update 26 September 2007:
It gets worse. Google Autofill has picked up the word "Area" in a table of user-generated content, and decided that the field next to it (which has nothing to do with any sort of area, but is an edit box) must want my Area Phone Code. Except that I am in the UK, and our area codes aren't in the 3-digit format that Google expects. No worry, Google will decide that I'd probably like the first three digits of my UK area telephone code inserting whenever the word "area" appears next to a text box.

Fair enough - Google does enter that value automatically. But if the user has signed up for Autofill, Google interferes with the page to change the input to have a yellow background [background-color: rgb(255,255,160); - ie
#ffffa0]

There is a solution in IE using "attachevent"
but it doesn't work in Firefox. Some have suggested adding
autocomplete='off'
to the specification of the input box, but that doesn't work in Firefox either.

For Firefox, the best that can be done is to over-rule the change to the background-color setting by using CSS like this:
.whitebox{
background-color: white !important;
}
(or an inline style that does the same). The "Important" setting will overrule the Google setting. However, anyone hitting the Autofill button on the toolbar will still get the nonsense data inserted.

Autofill is neat, but surely Google owes the world a method that allows developers to indicate that a form field - whatever its name or nearby text - is liable to fool the Autofill program, and so should be granted exemption from having its colour modified and Autofill enabled.

No comments: