Input Submit formEnctype Attribute

Definition and Usage

formEnctype Sets or returns the value of the formenctype attribute of the submit button.

The HTML formenctype attribute specifies how form data should be encoded when submitted to the server (only applicable to forms with method="post").

The formenctype attribute overrides the <form> element's enctype attribute.

Note:The formenctype attribute is a new attribute of the <input> element with type="submit" in HTML5.

See Also:

HTML Reference Manual:HTML <input> formenctype Attribute

Instance

Example 1

Find out how to encode form data before submitting it to the server:

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

Try It Yourself

Example 2

Change the formenctype attribute value of the submit button to "application/x-www-form-urlencoded":

document.getElementById("mySubmit").formEnctype = "application/x-www-form-urlencoded";

Try It Yourself

Syntax

Return the formEnctype attribute:

submitObject.formEnctype

Set the formEnctype attribute:

submitObject.formEnctype = "application/x-www-form-urlencoded,multipart/form-data,text/plain"

Attribute Value

Value Description
application/x-www-form-urlencoded Default. All characters are encoded before sending (spaces are converted to "+" symbol, special characters are converted to ASCII HEX values).
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 the "+" symbol, but special characters are not encoded.

Technical Details

Return Value: A string value representing the content type used to submit the form to the server.

Browser Support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support