Form enctypeProperty
Form Object
Definition and Usage
The enctype property sets or returns the MIME type used to encode the form content.
If the form has no enctype attribute, the default value when submitting text is "application/x-www-form-urlencoded".
When the input type is "file", the value is "multipart/form-data".
Syntax
formObject.enctype=value
The enctype attribute can be the following values:
| Value | Description |
|---|---|
| application/x-www-form-urlencoded | All characters are encoded before data is sent (default) |
| multipart/form-data | No characters are encoded. This value is used for controlling form file uploads |
| text/plain | Spaces are converted to "+" symbols, but no special characters are encoded. |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the enctype attribute
Note:Internet Explorer and Safari browsers return "application/x-www-form-urlencoded" if no enctype attribute is defined (default value), other browsers have no return value.
Example
Example
Return the encoding type used to send form data to the server:
<html>
<body>
<form>
<form id="frm1" enctype="text/plain">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
</form>
<script>
document.write(document.getElementById("frm1").enctype);
</script>
</body>
</html>
<body>
<form>
<form id="frm1" enctype="text/plain">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
</form>
<script>
document.write(document.getElementById("frm1").enctype);
</script>
</body>
</html>
The above example outputs:
text/plain
Try it yourself »
Form Object Other Extensions