HTML 表单字段是否有命名约定,可以在所有现代浏览器中实现良好的自动完成功能?
表单字段有命名约定吗? Chrome、IE、Firefox 寻找哪些领域?我的意思是,适用于所有人,或者至少适用于大多数现代浏览器。
我偶然发现:
- http://wonderouslyflawed.com/2009/02/17/ Rails-forms-微格式
- http://acidmartin.wordpress.com/2008/10/28/using-ecml-11-to-make-website-forms-company-with-google-toobar-autofill-and-wand/->谈论 http://www.ietf.org/rfc/rfc3106.txt
- < a href="https://stackoverflow.com/questions/2142591/names-of-html-form-naming-conventions">HTML表单命名的名称约定
- 表单个人数据在浏览器(Safari、Opera)中自动填写的字段名称
例如,ECML 方法使用这样的名称:
Description Field name
----------------------------------------------------------
ship to title Ecom_ShipTo_Postal_Name_Prefix
ship to first name Ecom_ShipTo_Postal_Name_First
ship to middle name Ecom_ShipTo_Postal_Name_Middle
ship to last name Ecom_ShipTo_Postal_Name_Last
user ID Ecom_User_ID
user password Ecom_User_Password
但是那些“Ecom_...”表单字段对我来说似乎很奇怪?
我知道 IE 专有的(当然)属性 VCARD_NAME="vCard.xyz"
,但它是一个无效的 html 属性。
或者是最好的选择,以最常见的方式编写字段,如 @FB 建议的 浏览器(Safari、Opera)中个人数据自动填写使用的表单字段名称
小更新(2015-07-21) - 偶然发现了这个 Google 开发者博客帖子提到了自动填充的 WHATWG HTML 规范:
Is there a naming convention for form fields? For what fields do Chrome, IE, Firefox look for? I mean, one for all, or at least most of the modern browsers.
I stumbled upon:
- http://wonderfullyflawed.com/2009/02/17/rails-forms-microformat
- http://acidmartin.wordpress.com/2008/10/28/using-ecml-11-to-make-website-forms-compatible-with-google-toobar-autofill-and-wand/ -> talking about http://www.ietf.org/rfc/rfc3106.txt
- Names of HTML form naming conventions
- Form field names used by personal data auto-fill in browsers (Safari, Opera)
e.g. the ECML approach uses such names:
Description Field name
----------------------------------------------------------
ship to title Ecom_ShipTo_Postal_Name_Prefix
ship to first name Ecom_ShipTo_Postal_Name_First
ship to middle name Ecom_ShipTo_Postal_Name_Middle
ship to last name Ecom_ShipTo_Postal_Name_Last
user ID Ecom_User_ID
user password Ecom_User_Password
But those "Ecom_..." form fields appear odd to me?
I know about the IE-only and proprietary (of course) attribute VCARD_NAME="vCard.xyz"
, but it's an invalid html attribute.
Or is the best shot, to write the fields in the most common way like @F. B. suggests at Form field names used by personal data auto-fill in browsers (Safari, Opera)
Small Update (2015-07-21) - just stumbled upon this Google Developer Blog post which mentions the WHATWG HTML specs for Autofill:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎已链接到答案。但是,如果您不使用 CakePHP 或 Ruby on Rails 等高级框架,则第一个和第三个链接不适用。
问题是,成功填写表单是 Google 工具栏和 Wand 的工作。考虑到互联网的范围,工具栏必须有大量的冗余。
因此,只要您保持表单字段语义命名,表单就应该自动填充。
ECML 是电子商务建模语言。
Ecom_
简单地代表电子商务。如果您需要出售东西,请使用该命名约定。You seem to have linked to the answers. If you are not using high-level frameworks like CakePHP or Ruby on Rails, though, the first and third links do not apply.
The thing is, it's Google Toolbar and Wand's job to fill out forms successfully. Given the scope of the internet, the toolbar must have tons of redundancy.
Therefore, as long as you keep your form fields semanticly named, the form should autofill.
ECML is E-Commerce Modeling Language.
Ecom_
simply stands for E-Commerce. If you need to sell stuff, use that naming convention.