formenctype属性指定在将表单数据发送到服务器之前应如何编码。此属性将覆盖表单的 enctype 属性。formenctype属性仅用于type ="submit"的按钮。
在线示例
具有两个提交按钮的表单。第一个提交按钮使用默认字符编码提交表单数据,第二个提交按钮不使用字符编码提交表单数据:
<!DOCTYPE html> <html> <head> <title>HTML:<button> formenctype 属性 - 大卫编程网 div.cn</title> <body> <form action="demo-form.php" method="post"> Name: <input type="text" name="fname" value="Ståle Refsnes"><br> <button type="submit">使用字符编码提交</button> <button type="submit" formenctype="text/plain">不使用字符编码提交</button> </form> </body> </html>测试看看 ‹/›
浏览器兼容性
IEFirefoxOperaChromeSafari
Internet Explorer 10, Firefox, Opera, Chrome, 和 Safari 支持 formenctype属性。
注意: Internet Explorer 9 及更早IE版本不支持 formenctype属性。
定义和用法
formenctype属性指定在将表单数据发送到服务器之前应如何编码。此属性将覆盖表单的 enctype 属性。
formenctype属性仅用于type ="submit"的按钮。
HTML 4.01 与 HTML 5 之间的差异
formenctype 属性是 HTML 5 中的新属性。
语法
<button type="submit" formenctype="value">
属性值
值 | 描述 |
---|---|
application/x-www-form-urlencoded | 在发送前对所有字符进行编码(默认)。 |
multipart/form-data | 不对字符编码。当使用有文件上传控件的表单时,该值是必需的。 |
text/plain | 将空格转换为 "+" 符号,但不编码特殊字符。 |