Button formEnctype attribute
Definition and usage
formEnctype
Attribute sets or returns the button's formenctype attribute value.
The formenctype attribute specifies how form data should be encoded before being sent to the server. This attribute overrides the form's enctype attribute.
The formenctype attribute is only used for buttons with type="submit".
Note:formenctype attribute It is a new attribute of the <button> element in HTML5.
Instance
Example 1
Return how the form data should be encoded before sending it to the server:
var x = document.getElementById("myBtn").formEnctype;
Example 2
Change the formenctype attribute value of the button from "text/plain" to "application/x-www-form-urlencoded":
document.getElementById("myBtn").formEnctype = "application/x-www-form-urlencoded";
Example 3
Another example of returning the formEnctype attribute:
var x = document.getElementById("myBtn").formEnctype;
Syntax
Return the formEnctype attribute:
buttonObject.formEnctype
Set the formEnctype attribute:
buttonObject.formEnctype = "application/x-www-form-urlencoded,multipart/form-data,text/plain"
Attribute value
Value | Description |
---|---|
application/x-www-form-urlencoded | All characters are encoded before sending (default). |
multipart/form-data | Characters are not encoded. This value is required when you use a form with a file upload control. |
text/plain | Spaces are converted to "+" symbols, but special characters are not encoded. |
Technical details
Return value: | A string value indicating the content type used to submit the form to the server. |
---|
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |
Related pages
HTML reference manual:HTML <button> formenctype attribute