HTML input formmethod property
Examples
The second submit button covers HTTP method the form:
<form action="demo-form.php" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="提交">
<input type="submit" formmethod="post" formaction="demo-post.php" value="使用 POST 提交">
</form>
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="提交">
<input type="submit" formmethod="post" formaction="demo-post.php" value="使用 POST 提交">
</form>
try it"
Browser Support
Internet Explorer 10, Firefox, Opera, Chrome and Safari support formmethod property.
Note: Internet Explorer 9 and earlier versions do not support formmethod property <input> tag.
Definition and Usage
formmethod property defines the HTTP method to send the form data to the action URL.
formmethod property overrides <form> element's method attribute.
Note: formmethod attribute type = "submit" and type = "image" used in conjunction.
Form data can be used as the form to send the URL variable (method = "get") or as a form of HTTP post transaction to send (method = "post").
About "get" method Notes:
- The method of the form data is appended to the name / value pairs to the URL
- This method for user wants to bookmark useful form submission
- URL length is limited (different browsers limit is not the same), so you can not determine whether all the form data can be transferred correctly
- Never use the "get" way to send sensitive data! (Such as passwords or other sensitive information in the browser address bar is visible),
About "post" method Notes:
- This method sends the form data in the form of HTTP post transaction
- Forms submitted through the "post" method can not be bookmarked
- "Post" method is more secure than "get", and the "post" no length limit
Differences between HTML 4.01 and HTML5
formmethod attribute is new in HTML5 attributes.
grammar
<input formmethod="get|post">
Property Value
值 | 描述 |
---|---|
get | 默认。将表单数据(form-data)以名称/值对的形式附加到 URL:URL?name=value&name=value。 |
post | 以 HTTP post 事务的形式发送表单数据(form-data)。 |
HTML <input> tag