Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

html - Multiple form ID's in HTML5's input form attribute

The HTML5 input element includes a 'form' attribute, which can contain one or more space delimited form id's. See below for a simplified example, where both form1 and form2 share an input element.

<form id="form1" method="post">
    <input type="submit">
</form>

<form id="form2" method="post">
    <input type="submit">
</form>

<input type="text" form="form1 form2">

At least, that's how it's supposed to work:
http://swatelier.info/at/forms/HTML5attrib.asp
http://www.w3schools.com/tags/att_input_form.asp

In Chrome 28, I see that adding a second form id hides an input element from both forms. What modern browsers, if any, support this functionality?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Nowhere in the spec says that the value of the form attribute is a space-separated list of IDs of form elements in the document:

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.

Source: WHATWG HTML5 specification


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...