Open In App

HTML | <button> formenctype Attribute

Last Updated : 20 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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 characters into its hex value.
  • multipart/form-data: This value does not encode any character.
  • text/plain: This value converts spaces into + symbols but special characters are not converted.

Example: This Example illustrates the use of enctype attribute in <button> element.  

HTML




<!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>


Output: 

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

  • Google Chrome 9.0 and above
  • Edge 12.0 and above
  • Internet Explorer 10.0 and above
  • Firefox 4.0 and above
  • Opera 10.6 and above
  • Safari 

 



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

Similar Reads