The formmethod
attribute on a submit button specifies the HTTP method to use when the form is submitted.
This attribute can be applied to a <button> or <input> element of type submit.
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>
For additional details see our HTML button formmethod Reference.
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 be applied to a <button> or <input> element of type submit.
<tagname type="submit" formmethod="application/x-www-form-urlencoded | multipart/form-data | text/plain">
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). |
The following elements accept the formmethod
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". |
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>
For additional details see our HTML input formmethod Reference.
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 |