HTML 表单字段是否有命名约定,可以在所有现代浏览器中实现良好的自动完成功能?

发布于 2024-11-15 15:50:08 字数 2199 浏览 6 评论 0原文

表单字段有命名约定吗? Chrome、IE、Firefox 寻找哪些领域?我的意思是,适用于所有人,或者至少适用于大多数现代浏览器。

我偶然发现:

例如,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 规范:

https://html.spec.whatwg.org/multipage/forms .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:

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:

https://html.spec.whatwg.org/multipage/forms.html#autofill

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

五里雾 2024-11-22 15:50:08

您似乎已链接到答案。但是,如果您不使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文