The formaction attribute on a submit <button> tag specifies the form-handler the form data will be sent to.
This attribute requires that the <button> is of type submit.
A submit <button> with a formaction attribute. This attribute overrides the action specified on the <form> -- in this case, with JavaScript.
<form action="/tutorial/action.html">
<input type="text" name="email" placeholder="Enter your email">
<button type="submit">Submit 1</button>
<button type="submit" formaction="javascript:alert('Submit 2 formaction')">Submit 2</button>
</form>
Tip: The formaction can also be JavaScript as seen in the above example.
The formaction attribute overrides the form's action value, if present.
This attribute specifies the URL where the form data will be sent to.
The formaction attribute requires that the button is of type="submit"
.
<button type="submit" formaction="URL">
Value | Description |
---|---|
URL | A page or resource to which form data will be sent. |
Here is when formaction support started for each browser:
Chrome
|
9.0 | Feb 2011 |
Firefox
|
4.0 | Mar 2011 |
IE/Edge
|
10.0 | Sep 2012 |
Opera
|
15.0 | May 2013 |
Safari
|
5.1 | Oct 2011 |
Back to <button>