HTML <button> formmethod Attribute

The formmethod attribute on a <button> specifies the HTTP method to use when the form is submitted. This attribute can only be applied to submit type buttons.

Example

#

The second <button> has a formmethod attribute.
It overrides the method of the form.

<form action="/tutorial/action.html" method="post">
  <input type="text" name="email" placeholder="Enter your email">

  <button type="submit">Submit using POST</button>
  <button type="submit" formmethod="get">Submit using GET</button>
</form>

Using formmethod

The formmethod attribute overrides the form's method attribute.

This attribute specifies which HTTP method will be used when form data is sent to the server.

If this attribute is set to get, the form data will be sent using URL name-value pairs.

If post is used, the data will be sent as an HTTP post transaction.

Note: The formmethod attribute only works for submit type buttons.


Syntax

<button type="submit" formmethod="get | post">

Values

#

Value Description
get Sends the form-data using URL name-value pairs (e.g. URL?firstname=Wilsom&lastname=Smith).
post Sends the form-data as an HTTP post transaction.
This method should be used when the data being sent is sensitive (e.g. passwords, bank information).

Browser support

Here is when formmethod 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

 Back to <button>
Guides