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 for 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 属性
Instance
Example 1
Mag-aral kung paano ito ay nangangode bago ito ay ipapadala sa server ang form data:
var x = document.getElementById("mySubmit").formEnctype;
Example 2
Gawain 2: Palitan ang halaga ng formenctype attribute ng sumite button sa "application/x-www-form-urlencoded":
document.getElementById("mySubmit").formEnctype = "application/x-www-form-urlencoded";
Syntax
Return formEnctype attribute:
submitObject.formEnctype
Set formEnctype attribute:
submitObject.formEnctype = "application/x-www-form-urlencoded,multipart/form-data,text/plain"
Attribute Value
Value | Description |
---|---|
application/x-www-form-urlencoded | Default. Lahat ng character ay nangangode bago ito ipapadala (ang espasyo ay nababago sa simbolo na "+", ang mga espesyal na character ay nababago sa ASCII HEX halaga). |
multipart/form-data | Hindi nangangode ang mga character. Kapag gumagamit ka ng form na may file upload control, ang halaga na ito ay kinakailangan. |
text/plain | 空格转换为 "+" 符号,但不编码特殊字符。 |
技术细节
返回值: | 字符串值,表示用于向服务器提交表单的内容类型。 |
---|
浏览器支持
表中的数字注明了首个完全支持该属性的浏览器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 10.0 | 支持 | 支持 | 支持 |