输入表单属性可以指定多个表单ID吗?或不? [英] Can input form attribute specify multiple form ids? Or not?

查看:125
本文介绍了输入表单属性可以指定多个表单ID吗?或不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

w3schools 指定: 定义和用法: 表单属性指定了元素所属的一个或更多表单." 在 http://www.w3schools.com/tags/att_input_form.asp

w3schools specify: "Definition and Usage: The form attribute specifies one or more forms the element belongs to." at http://www.w3schools.com/tags/att_input_form.asp

和 提示:要引用多个表单,请使用以空格分隔的表单ID列表." 在 http://www.w3schools.com/html/html5_form_attributes.asp

and "Tip: To refer to more than one form, use a space-separated list of form ids." at http://www.w3schools.com/html/html5_form_attributes.asp

developer.mozilla .org指出: 输入只能与一种形式相关联." 在 https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input

while developer.mozilla.org states: "An input can only be associated with one form." at https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input

谁在这里?

推荐答案

没有确定的肯定答案.只能说,由于在w3联盟规范中没有任何地方声明输入可以与多种形式相关联,因此它暗示不能这样做. (还有一个结论,如CBroe所指出的,w3schools信息应与一粒盐一起服用).

There is no definite affirmative answer. It seams that we can only say that, since nowhere in the w3 consortium specs it is stated that an input can be associated with multiple forms, it implies that it cannot; (and also a conclusion that w3schools info should be taken with a grain of salt as CBroe noted).

当我对其进行测试时-使用ID为"form1"和"form2"的两个表单,以及一个将form-attribute设置为form ="form1 form2"的'外部'输入元素-此输入没有使用这两个表单提交.这意味着,由于form-attribute并未完全设置为一个表单id,因此它不会将其连接到任何表单.

When I tested it - using two forms with ids "form1" and "form2", and an 'outside' input element with form-attribute set to form="form1 form2" - this input did not submit with neither of forms. Meaning that, since form-attribute is not exactly set to one form id, it doesn't connect it to any form.

在测试中,我还添加了第三种形式,其形式为id ="form1 form2".这导致输入元素(在所有表单之外,并且form-attribute设置为form ="form1 form2")使用此表单提交,但不使用id ="form1"的表单或带有id的表单提交="form2".

Further in the test I have added a third form with form id="form1 form2". This resulted in input element (which is outside of all of the forms, with form-attribute set to form="form1 form2") to get submitted with this form, but not with form with id="form1" nor with form with id="form2".

因此,据我所知,我敢作一个结论:

Therefore, with my limited knowledge, I dare to make a conclusion:

一个输入元素不能通过为表单属性指定以空格分隔的id(或最有可能的其他方式)来与多个表单相关联.

此问题是 HTML5输入表单中的多个表单ID的重复属性,但此处有更详细的说明.

This question is a duplicate of Multiple form ID's in HTML5's input form attribute, but there is a bit more detailed explanation here.

这篇关于输入表单属性可以指定多个表单ID吗?或不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆