对(表单属性)感到困惑 [英] Confuse about ( Form attribute )

查看:80
本文介绍了对(表单属性)感到困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用form属性(Form =")感到困惑

I'm confused about using the form attribute (Form=" ")

来自 MDN

一个输入最多可以与一种形式相关联.

An input can be associated with at most one form.

来自 W3S

form属性指定一个或多个form元素 属于.
要引用多个表格,请使用 以空格分隔的表单ID列表.

The form attribute specifies one or more forms an element belongs to.
To refer to more than one form, use a space-separated list of form ids.

因此,我可以将输入与多个表格相关联吗?是否?
哪一个是对的?

So,Can i associate an input with more than one form ? or not ?
Which one is true ?

推荐答案

否. from属性在HTML5发行之前不存在.您需要查看您的DOCTYPE并做出确定.

No.. The from attribute did not exist prior to HTML5's release. You will need to look at your DOCTYPE and make that determination.

在HTML5之前,您可以使用Javascript并使用Xhr做一些事情来实现这种行为,但是实际上是必需的.

Before HTML5, you could use Javascript and do some stuff with Xhr to accomplish that type of behavior if it was actually needed however.

我找到了您引用的示例 ...

I found the example you cited...

Last name: <input type="text" name="lname" form="form1">

这是HTML5表单规范中的描述: https://www.w3.org/TR/html5/sec-forms.html#element-attrdef-formelements-form

Here is the description in HTML5 Form Specs: https://www.w3.org/TR/html5/sec-forms.html#element-attrdef-formelements-form

此功能使作者可以解决缺少以下方面的支持 嵌套的表单元素.

This feature allows authors to work around the lack of support for nested form elements.

如果可重新关联的表单关联元素具有表单属性 指定,那么该属性的值必须是表单的ID 元素所有者文档中的元素.

If a reassociateable form-associated element has a form attribute specified, then that attribute’s value must be the ID of a form element in the element’s owner Document.

在RFC中还有其他一些注释.建议在那里看看.

Quite a few other comments in the RFC. Recommend taking a look there.

好文章: https://www.impressivewebs.com/html5-form-attribute /

已更新 经过更多考虑之后,看不到任何暗示表单属性可以指定多个表单的内容.支持W3C规范的最简洁的文本为:表单-将控件与 a 表单元素相关联" .

Updated after more consideration not seeing anything which suggests a form attribute can specify more than one form. Most concise text from W3C spec to support that would be: "form - Associates the control with a form element".

这篇关于对(表单属性)感到困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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