Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML formaction Attribute

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>.

Example

#

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.


Using formaction

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".


Syntax

<tagname type="submit | image" formaction="URL" >

Values

#

Value Description
URL A page or resource to which form data will be sent.

Elements that accept formaction

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".

<input> with formaction

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.


Browser support

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

You may also like




Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides