Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML formenctype Attribute

The formenctype attribute on a submit button sets the data encoding to use when the form is submitted.

This attribute can be applied to a <button> or <input> element of type submit.

Example

#

The second button has a formenctype attribute.
This overrides the enctype of the form.

<form action="/tutorial/action.html" enctype="multipart/form-data">
  <input type="text" name="subject" placeholder="Enter subject">

  <button type="submit">Submit as encoded text</button>
  <button type="submit" formenctype="text/plain">Submit as plain text</button>
</form>

For additional details see our HTML button formenctype Reference.


Using formenctype

The formenctype attribute overrides the form's enctype attribute.

This attribute specifies how the form data will be encoded before sending it to the server.

This attribute is only used on <button> and <input> elements with type submit or image.


Syntax

<tagname type="submit" 
         formenctype="application/x-www-form-urlencoded | 
                      multipart/form-data | 
                      text/plain">

Values

#

Value Description
application/x-www-form-urlencoded All form data characters will be encoded before sending to the server. This is default.
multipart/form-data Form data characters are encoded before sending to the server. This value is used for forms that has upload function.
text/plain Spaces are converted to "+" symbols but no characters will be encoded.

Elements that accept formenctype

The following elements accept the formenctype attribute.

Elements Description
<button> Must be a clickable button with type="submit" -- see example above
<input> Must be an input element with type="submit" or type="image".

<input> with formenctype

An <input> tag, of type submit, with a formenctype attribute.
This button will submit form data as plain text.

<form action="/tutorial/action.html" enctype="multipart/form-data">
  <input type="text" name="email" placeholder="Enter email">

  <input type="submit" value="Submit as encoded text"/> 
  <input type="submit" formenctype="text/plain" value="Submit as plain text"  />
</form>

For additional details see our HTML input formenctype Reference.


Browser support

Here is when formenctype support started for each browser:

Chrome
9.0 Feb 2011
Firefox
4.0 Mar 2011
IE/Edge
10.0 Sep 2012
Opera
11.5 May 2011
Safari
5.1 Oct 2011

You may also like




Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides