Input Submit formEnctype Attribute

Definition and Usage

formEnctype Set or return 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 type="submit" <input> element in HTML5.

See also:

HTML Reference Manual:HTML <input> formenctype egenskap

Instance

Example 1

Find out how to encode the 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

Set the formEnctype attribute:

submitObject

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 Characters are not encoded. This value is required when you use a form with a file upload control.
text/plain Mellanslag konverteras till "+"-tecken, men specialtecken kódas inte.

Tekniska detaljer

Returvärde: Strängvärde som anger innehålletstypen som används för att skicka formulär till servern.

Webbläsarstöd

Numrerna i tabellen anger den första webbläsaren som helt stöder egenskapen.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Stöd 10.0 Stöd Stöd Stöd