CSS Portal

HTML formaction Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
formaction
HTML AttributeThis attribute is supported by all modern browsers.
Updated 29th March 2024

Description

The formaction attribute in HTML is an attribute that can be used within <button> or <input type="submit"> elements to specify the URL of the file that will process the form data upon form submission. This attribute essentially overrides the action attribute of the form element to which it belongs, allowing different submit buttons in the same form to send the data to different URLs.

This feature is particularly useful when you have a single form that needs to perform different actions depending on which submit button is clicked by the user. For instance, one button could be used to save the current state of the form, while another could submit the form for processing. By providing a formaction attribute to each button, you can direct the form data to different endpoints without needing to create multiple forms or use JavaScript for redirection.

The formaction attribute should contain a valid URL, which can be an absolute or relative path, and works with the GET and POST methods defined by the form's method attribute. It is supported in all major browsers, offering a simple way to control the flow of data for complex forms in a web application.

Syntax

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

Values

  • URLA page or resource to which form data will be sent.

Applies To

Example

<form action="formscript.php">
<input type="text" name="name" placeholder="Enter your name">
<input type="submit" value="Submit to Products">
<input type="submit" value="Submit to Contact Us" formaction="formcontact.php">
</form>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML formaction attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.

This attribute is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee