HTML | <button> formenctype Attribute

The HTML <button> formenctype Attribute is used to specify that the form data should be encoded when submitting to the server. This attribute will override the feature of the formencrypt attribute. It can only be used with the Button type= “submit”.

Syntax:

<button type="submit" formenctype="value">

Attribute value: This attribute contains three value which are listed below:



  • application/x-www-form-urlencoded: It is the default value. It encodes all the characters before sent to the server. It converts spaces into + symbols and special character into its hex value.
  • multipart/form-data: This value does not encode any character.
  • text/plain: This value convert spaces into + symbols but special characters are not converted.

Example: This Example illustrate the use of enctype attribute in <butoon> element.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title
     Button Formenctype attribute
    </title>
</head>
  
<body style="text-align: center">
    <h1 style="color: green">GeeksforGeeks</h1>
    <h4>HTML Button Formenctype Attribute</h4>
    <form action="#" method="post" 
          formenctype="multipart/form-data">
        First name:
        <input type="text" name="fname">
        <br><br>
        Last name:
        <input type="text" name="lname">
        <br><br>
        Address:
        <input type="text" name="Address">
        <br><br>
        <button type="submit">
          submit without character encoding 
        </button>
        <br>
        <br>
        <button type="submit" formenctype="text/plan">
          submit with character encoding
        </button>
    </form>
</body>
  
</html>

chevron_right


Output:

Supported Browsers: The browsers supported by HTML <button> formenctype attribute are listed below:

  • Google Chrome 10.0
  • Internet Explorer 10.0
  • Firefox 4.0
  • Opera 10.6
  • Safari 5.1


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.