The form attribute specifies one or more forms which an <input> element belongs to. This example shows an input field located outside the HTML form (but still a part of the form):
HTML file: | Displayed by browser: |
---|---|
<form action="http://www.w3schools.com/html/action_page.php" id="form1">
First name: <input type="text" name="fname"> <br /> <br /><input type="submit" value="Submit"> </form> <br /><br /><br /><br /> Last name: <input type="text" name="lname" form="form1"> |
Last name: |
Tip: To refer to more than one form, use a space-separated list of form ids. This will not work with Internet Explorer, but should with the other major browsers.