iwato Posted April 23, 2017 Share Posted April 23, 2017 QUESTION ONE: When using the form attribute with a non-form element to redirect the contents of the non-form element to the form element, will confusion be created, if the non-form element is included in a form element different from the form element that contains the type='submit' input element? QUESTION TWO: Are fieldset elements an exception in this regard? Or, are they, too, treated as non-form elements. Link to comment Share on other sites More sharing options...
Ingolme Posted April 23, 2017 Share Posted April 23, 2017 The form attribute only applies to form control elements. It doesn't exist on elements like <div> or <p>. What kind of element are you referring to when you say "non-form element"? This is regarding the form attribute from the MDN page for the <input> element: Quote The form element that the input element is associated with (its form owner). The value of the attribute must be an id of a <form> element in the same document. If this attribute is not specified, this <input> element must be a descendant of a <form> element. This attribute enables you to place <input> elements anywhere within a document, not just as descendants of their form elements. An input can only be associated with one form. When the element is a descendant of a <form> element the form attribute is not needed. If the element is not inside a <form> then the form attribute will indicate which form the element belongs to so that when the form is submitted the element's value is added to the data that is sent. I'm not certain how fieldset elements behave, I would guess that the fieldset's children would belong to the same form that the fieldset belongs to, but it can be easily confirmed with an experiment. Experiments can be done with the form attribute by submitting the form and seeing which values get sent to the server. My guess before doing experiments is that a child of one form that has a form attribute from a different form will be added as a value when either of the two forms are submitted. 1 Link to comment Share on other sites More sharing options...
iwato Posted April 23, 2017 Author Share Posted April 23, 2017 Hi, Ingolme! I can see how use of the term form element can lead to confusion. On the one hand, it refers to the form tag <form>; on the other hand, it refers to any HTML element related directly to the creation of a form -- both non-control and control elements alike. Since the form attribute of the fieldset element is not recognized by any recent browser (see W3Schools), I will assume that it is a non-control form element only useful for decoration and the organization of form-control elements. To play it safe I will remove all of my non-essential <form> tags. Originally, all of my control-elements pointed to the same <form> tag, but each was grouped with other control elements in different <form> tags that did not contain a type='submit' control element. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now