The form attribute on a <button> tag specifies the form the button will submit.
The form
attribute requires that the <button> is of type submit.
A submit <button> with a form attribute. Although outside the form, this button does submit the form above it.
<form action="/tutorial/action.html" id="address-form">
<fieldset>
<legend>Address Information</legend>
<input type="text" name="street" placeholder="Street"><br /><br />
<input type="text" name="city" placeholder="City"><br /><br />
<input type="text" name="country" placeholder="Country"><br /><br />
</fieldset>
</form>
<button form="address-form"
type="submit" >Submit</button>
The form attribute specifies the form the button is associated with.
The attribute value is the id of the form.
Once associated to a form, the button can submit that form.
<button form="form-id">
Value | Description |
---|---|
form-id | The id value of the form. |
Here is when form support started for each browser:
Chrome
|
10.0 | Mar 2011 |
Firefox
|
4.0 | Mar 2011 |
IE/Edge
|
16.0 | Apr 2017 |
Opera
|
9.5 | Jun 2008 |
Safari
|
5.1 | Oct 2011 |
Back to <button>