1

How do browsers recognize if a particular field (like a username) should be prompted with autocompletes? Do they use some sort of regex to match the fields name attribute? Is there a standard I need to follow to ensure this?

I ask this because on some sites the browser fails to suggest any historical data.

Put simply, I am asking the exact opposite of what this person was trying to achieve:

How do you disable browser Autocomplete on web form field / input tag?

Community
  • 1
  • 1
Aditya M P
  • 5,127
  • 7
  • 41
  • 72
  • 1
    Depending on the browser, either the `name` or `id` attribute is used as a key to historical data. For example if you fill out and submit a form with `` and you then navigate to another site with `` then depending on your browser settings, it should autocomplete with historical data. – Christopher.Cubells Nov 01 '12 at 14:48

2 Answers2

2

With HTML5:

 <form action="demo_form.asp" method="get" autocomplete="on">
 First name:<input type="text" name="fname" /><br />
 E-mail: <input type="email" name="email" /><br />
 <input type="submit" />
 </form>

Source: http://www.w3schools.com/html5/att_form_autocomplete.asp

Chris Frank
  • 4,124
  • 4
  • 30
  • 42
  • 2
    Or this link http://www.w3.org/Submission/web-forms2/#the-autocomplete. Might as well visit http://w3fools.com/. – Daniel Le Nov 01 '12 at 14:51
  • 1
    Haha, they always come up first on Google. Must have some killer SEO specialists. Here is a jsFiddle with the above code: http://jsfiddle.net/y6TFt/ – Chris Frank Nov 01 '12 at 14:53
1

In my experience it's based on matching the name or id attribute of the input tag. Which is why you generally find that username, email and name fields tend to autocomplete on a number of different websites.

I think the matching has to be exact, not a regex or partial match on the field.

munnster79
  • 578
  • 3
  • 16