重复的隐藏表格,没有唯一的输入ID

发布于 2025-01-26 02:18:29 字数 445 浏览 2 评论 0原文

我的布局需要在2个不同的位置具有相同形式的移动和桌面查看

我所做的是将两个或另一个藏在一个或另一个基于视口大小的容器中,

我正在使用Google Lighthouse测试字段ID不是唯一的 有什么方法可以在不处理不同ID的2个表单字段的情况下进行修复?

我总是添加具有相同ID和名称的输入字段,

<input type="text" class="form-control" id="name" name="name" value="" required>

我想如果我在保持字段名称相同的同时区分ID,我将不会有任何问题

<input type="text" class="form-control" id="name-mobile" name="name" value="" required>

I have a layout that require to have the same form in 2 different place for mobile and desktop view

What I did is to wrap both in a container that hide one or another based on viewport size

I was testing with Google Lighthouse and it complains that form field ID are not unique
Any way to fix this without handle the 2 form field with different ID?

I always add input field with the same ID and NAME

<input type="text" class="form-control" id="name" name="name" value="" required>

I guess I will not have any issue with post variables if I differentiate ID while keeping field name the same

<input type="text" class="form-control" id="name-mobile" name="name" value="" required>

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

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

发布评论

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

评论(1

断桥再见 2025-02-02 02:18:29

ID必须在HTML文档中是唯一的,因此不,如果不更改ID,就无法执行此操作。

我想,如果我在保持字段名称相同的同时划分ID,我将不会有任何问题

我想,如果我区分ID的同时保留字段名称相同的ID在创建表单提交数据集时没有任何相关性, 。问题是,从这里特别是真正需要ID。

IDs must be unique within an HTML document, so no, there is no way to do this without changing the IDs.

I guess I will not have any issue with post variables if I differentiate ID while keeping field name the same

IDs have no relevance whatsoever in creating the form submission data set. Question would be, whether IDs are actually needed for anything in particular here to begin with.

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