HTML <button> formenctype 属性
定义和用法
formenctype
属性规定在将表单数据发送到服务器之前应如何对其进行编码。此属性覆盖表单的 enctype 属性。
formenctype
属性仅用于 type="submit"
的按钮。
实例
带有两个提交按钮的表单。第一个提交按钮提交默认字符编码的表单数据,第二个提交没有字符编码的表单数据:
<form action="/action_page_binary.asp" method="post"> <label for="fname">姓氏:</label> <input type="text" id="fname" name="fname" value="Bill"><br><br> <button type="submit">带字符编码提交</button> <button type="submit" formenctype="text/plain">不带字符编码提交</button> </form>
语法
<button type="submit" formenctype="value">
属性值
值 | 描述 |
---|---|
application/x-www-form-urlencoded | 默认。所有字符将在发送前进行编码。 |
multipart/form-data | 当使用有文件上传控件的表单时,则此值是必需的。 |
text/plain | 发送没有任何编码的数据。不建议。 |
浏览器支持
表中的数字注明了首个完全支持该属性的浏览器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
9.0 | 10.0 | 4.0 | 5.1 | 11.5 |