问题
How does Chrome, or other browsers, determine what data is appropriate to auto-complete into a particular form field? Is it just based on the name and type? Are there other semantic / microdata standards I should be aware of that can give it a hint?
I seem to recall reading a standard of form field hints for chrome, but I can't find that article anymore.
回答1:
HTML5 defines:
When the autofill field name is "
on
", the user agent should attempt to use heuristics to determine the most appropriate values to offer the user, e.g. based on the element'sname
value, the position of the element in the document's DOM, what other fields exist in the form, and so forth.
Several autofill field names are defined, that can be used as values for the autocomplete
attribute, for example:
name
for the full namenickname
for the nickname, screen name, etc.organization-title
for the job titlebday
for the birthdaytel
for the telephone number- …
(FWIW, there is also RFC 3106 which defines values for e-commerce.)
Update (2015): These autofill field names did not make it to the HTML5 REC. However, they are again/still part of HTML 5.1 (WD), and currently also part of the Editor’s Draft.
Update (2016): It’s part of HTML 5.1 (REC): Autofill.
回答2:
Microformats!
http://microformats.org/
They are open data formats based upon already existing standards.
vCard, hCard, etc!
来源:https://stackoverflow.com/questions/20362089/how-can-i-write-a-form-that-assists-my-browsers-auto-complete-feature