How can I write a form that assists my browser's auto-complete feature?

 ̄綄美尐妖づ 提交于 2019-12-06 07:23:01

问题


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's name 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 name
  • nickname for the nickname, screen name, etc.
  • organization-title for the job title
  • bday for the birthday
  • tel 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!