HTML <input> formmethod Attribute

The formmethod attribute on an <input> button specifies the HTTP method to use when the form is submitted. This attribute only applies to input types submit and image.

Example

#

The second <input> 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">

  <input type="submit" value="Submit using POST"/>
  <input type="submit" formmethod="get" value="Submit using GET" />
</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.

This attribute can only be used for input which types are submit or image.


Syntax

<input type="submit | image" 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
1.0 Dec 2008
Firefox
1.0 Nov 2004
IE/Edge
10.0 Sep 2012
Opera
10.6 Oct 2010
Safari
5.1 Oct 2011

You may also like

 Back to <input>
Guides