Form enctype attribute
Definition and Usage
enctype
Sets or returns the value of the enctype attribute in the form.
The HTML enctype attribute specifies how form data should be encoded before being sent to the server.
By default, form data is encoded as "application/x-www-form-urlencoded". This means that all characters are encoded before being sent to the server (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values).
See also:
HTML Reference Manual:خصوصیت enctype <form> HTML
Example
Example 1
Return how the form data should be encoded before sending it to the server:
var x = document.getElementById("myForm").enctype;
Example 2
Change the enctype value to set how the form data should be encoded before sending it to the server:
document.getElementById("myForm").enctype = "multipart/form-data";
Syntax
Return enctype attribute:
formObject.enctype
Set enctype attribute:
formObject.enctype = "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 | هیچ کاراکتری کدگذاری نمیشود. این مقدار برای فرمهایی که دارای کنترلهای بارگذاری فایل هستند، ضروری است. |
text/plain | جابجایی فضاهای خالی به نشانه "+" انجام میشود، اما کاراکترهای خاص کدگذاری نمیشوند. |
جزئیات فنی
مقدار بازگشتی: | مقدار رشتهای که نشاندهنده نحوه کدگذاری دادههای فرم قبل از ارسال به سرور است. |
---|
پشتیبانی مرورگر
اعداد در جدول نشاندهنده نسخه اولین مرورگری است که از این ویژگی پشتیبانی میکند.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
پشتیبانی | پشتیبانی | پشتیبانی | پشتیبانی | پشتیبانی |