English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The formmethod attribute defines the HTTP method used to send form data to the operation URL. The formmethod attribute overrides the method attribute of the <form> element. Note: The formmethod attribute can be used with type = 'submit' and type = 'image'.
The second submit button will override the following HTTP method form:
<!DOCTYPE html> <html> <head> <title>HTML:<input> formmethod Attribute - 基础教程网(oldtoolbag.com)</title>/title> <body> <form action="action_page.php" method="get" target="_blank"> First name: <input type="text" name="fname"><br> Last name: <input type="text" name="lname"><br> <input type="submit" value="Submit"> <input type="submit" formmethod="post" value="Submit using POST"> </form> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
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 of the <input> tag.
The formmethod attribute defines the HTTP method used to send form data to the action URL.
The formmethod attribute overrides the HTTP method of the <form> element method Attribute.
Note:The formmethod attribute is used in conjunction with type="submit" and type="image".
Form data can be sent as URL variables (method="get") or as part of an HTTP post transaction (method="post").
Comments on the "get" method:
This method sends form data with the name/Value pairs are appended to the URL in the form
This method is very useful for form submissions that the user wants to add bookmarks to
The length of the URL is limited (different browsers have different limits), so you cannot be sure whether all the form data can be correctly transmitted
Never use the "get" method to send sensitive data! (such as passwords or other sensitive information, which is visible in the browser's address bar),
Comments on the "post" method:
This method sends form data in the form of an HTTP POST transaction
Forms submitted via the "post" method cannot be added to bookmarks
"post" method is more secure than "get", and "post" has no length limit
The formmethod attribute is an HTML5 of the new attribute.
<input formmethod="get|post">
Value | Description |
---|---|
get | Default. Send form data (form-data) by name/pairs appended to the URL: URL?name=value&name=value. |
post | Send form data in the form of an HTTP POST transaction (form-data). |