简体   繁体   中英

How do I ensure autocomplete works for a specific field?

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM