HTML <button>
formmethod
Attribute
Example
A form with two submit buttons, where the first button submits the form data using method="get"
, and the second button submits the form data using method="post"
:
Browser Support
Internet Explorer 10, Firefox, Opera, Chrome, and Safari support the formmethod
attribute.
Note: Internet Explorer 9 and earlier versions do not support the formmethod
attribute.
Definition and Usage
The formmethod
attribute specifies the HTTP method used to submit the form data. The formmethod
attribute overrides the method
attribute of the form element.
The formmethod
attribute must be used with type="submit"
.
Form data can be sent in the following ways:
Sent as URL variables (using
method="get"
)Sent as an HTTP post (using
method="post"
)
Using the "get" method:
Form data appears in the URL as name/value pairs.
The amount of data that can be sent using "get" is limited, not exceeding 2KB, primarily due to URL length restrictions.
Do not use the "get" method to send sensitive information! (Passwords or sensitive information will appear in the browser's address bar)
Using the "post" method:
Form data is sent as an HTTP post.
More powerful and secure than the "get" method.
No size limitations.
Differences Between HTML 4.01 and HTML5
The formmethod
attribute is a new attribute in HTML5.
Syntax
Attribute Values
Value | Description |
---|---|
get | Appends the form data (form-data) to the URL: URL?name=value&name=value |
post | Sends the form data (form-data) as an HTTP post transaction |