HTML <input> formmethod attribute

Definition and usage

formmethod attribute of the <form> element

formmethod attribute overrides the The method attribute.

Note:formmethod attributes can be combined with type="submit" and type="image" Together

Form data can be sent as URL variables (method="get") or as an HTTP post transaction (method="post")

Considerations regarding the "get" method:

  • It attaches form data in the form of name/value pairs to the URL
  • This is very useful for form submissions where users want to add the results as bookmarks
  • The amount of data that can be placed in the URL is limited (varies by browser), so it cannot be guaranteed that all form data can be transmitted correctly.
  • Never use the "get" method to pass sensitive information! (Passwords or other sensitive information will be displayed in the browser's address bar)

Considerations regarding the "post" method:

  • It sends form data as an HTTP POST transaction
  • Forms submitted using the "post" method cannot be saved as bookmarks
  • Compared to the "get" method, the "post" method is more robust and secure
  • It has no size limit

Example

The second submit button overrides the form's HTTP method:

<form action="/action_page.php" method="get">
  <label for="fname">Name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Surname:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
  <input type="submit" formmethod="post" value="Submit using POST">
</form>

Try It Yourself

Syntax

<input formmethod="get|post">

Attribute Value

Value Description
get Default. Attach form data as name/value pairs to the URL:URL?name=value&name=value.
post Send form data as an HTTP POST transaction.

Browser Support

The numbers in the table indicate the first browser version to fully support this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support 5.1 10.6