The formaction
attribute on a submit button specifies the form-handler the form data will be sent to.
Elements that accept this attribute include <input>, and <button>.
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>
For additional details see our HTML button formaction Reference.
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 element is a button of type "submit" or "image".
<tagname type="submit | image" formaction="URL" >
Value | Description |
---|---|
URL | A page or resource to which form data will be sent. |
The following elements accept the formaction
attribute.
Elements | Description | |
---|---|---|
<button> | Must be a clickable button with type="submit" -- see example above | |
<input> | Must be an input element with type="submit" or type="image". |
An <input> tag, of type="submit", 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">
<input type="submit" value="Submit 1"/>
<input type="submit" value="Submit 2"
formaction="javascript:alert('Submit 2 formaction')" />
</form>
For additional details see our HTML input formaction Reference.
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 |