重复的隐藏表格,没有唯一的输入ID
我的布局需要在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ID必须在HTML文档中是唯一的,因此不,如果不更改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.
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.