Open In App

HTML | input formmethod Attribute

Last Updated : 12 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The HTML <input> formmethod Attribute is used to specify the HTTP method for sending form-data to the action URL. This attribute is used to override the method attribute of the <form> element. 

Syntax:

<input formmethod="get | post">

Attribute Values:

  • get: It has a default value. In the GET method, after the submission of the form, the form values will be visible in the address bar of the new browser tab. It has a limited size of about 3000 characters. It is only useful for non-secure data not for sensitive information.
  • post: In the post method, after the submission of the form, the form values will not be visible in the address bar of the new browser tab as it was visible in the GET method. It appends form data inside the body of the HTTP request. It has no size limitation. This method does not support bookmark the result.

Example: 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML input formmethod Attribute
    </title>
</head>
 
<body style="text-align:center;">
 
    <h1 style="color:green;">
      GeeksforGeeks
  </h1>
 
    <h3>HTML &lt;input&gt;
      formmethod Attribute</h3>
 
    <form action="#"
          id="users"
          action="#"
          method="GET"
          target="_blank">
 
        First name:
        <input type="text"
               name="fname"
               placeholder="Enter first name">
 
        <br>
        <br> Last name:
        <input type="text"
               name="lname"
               placeholder="Enter last name">
        <br>
        <br>
 
        <input type="submit"
               value="Submit"
               formmethod="post">
 
    </form>
</body>
 
</html>


Output:

  

Supported Browsers: The browsers supported by HTML input formmethod Attribute are listed below:

  • Google Chrome 9.0
  • Edge 12.0
  • Internet Explorer 10.0
  • Firefox 4.0
  • Safari 5.0
  • Opera 12.1


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads