I'm confused about using the form attribute (Form=" ")
From MDN
An input can be associated with at most one form.
From W3S
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 ?
No.. The from
attribute did not exist prior to HTML5's release. You will need to look at your DOCTYPE
and make that determination.
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">
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.
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.
Quite a few other comments in the RFC. Recommend taking a look there.
Good article: https://www.impressivewebs.com/html5-form-attribute/
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With