Input Submit formAction Attribute

Definition and Usage

formAction The attribute sets or returns the value of the formaction attribute of the submission button.

The HTML formaction attribute specifies the URL that will handle the input control file when the form is submitted.

The HTML formaction attribute overrides the action attribute of the <form> element. action attribute.

Note:In the following example, Internet Explorer and Opera 12 (and earlier versions) return "action_page2.php", while Firefox, Opera 15+, Chrome, and Safari return the entire URL: "https://www.codew3c.com/action_page2.php".

Note:The formaction attribute is a new attribute of the <input> element with type="submit" in HTML5.

See also:

HTML Reference Manual:HTML <input> formaction Attribute

Example

Example 1

Get the URL that will handle the input control file when the form is submitted:

var x = document.getElementById("mySubmit").formAction;

Try it yourself

Example 2

Change the URL to which the form data is sent:

document.getElementById("mySubmit").formAction = "/action_page2.php";

Try it yourself

Syntax

Return the formAction attribute:

submitObject.formAction

Set the formAction attribute:

submitObject.formAction = URL

Attribute value

Value Description
URL

Specifies the URL that will handle the input control file when the form is submitted.

Note:This will override the action attribute of the <form> element.

Possible values:

  • Absolute URL - the complete address of the page (such as href="http://www.example.com/formresult.asp")
  • Relative URL - Points to a file within the current site (e.g., href="formresult.asp"))

Technical Details

Return Value: A string value that indicates the URL to which the form data is sent.

Browser Support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support