Button formEnctype attribute

Definition and usage

formEnctype Property setting or returning 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;

Try it yourself

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";

Try it yourself

Example 3

Another example of returning the formEnctype attribute:

var x = document.getElementById("myBtn").formEnctype;

Try it yourself

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 Do not encode characters. 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 that indicates the content type used to submit a 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