HTML button formenctype 屬性
實例
帶有兩個提交按鈕的表單(帶有不同的編碼方式),第一個提交按鈕使用默認字符編碼提交表單數據,第二個提交按鈕不使用字符編碼提交表單數據:
<form action="demo_post_enctype.asp" method="post">
Name: <input type="text" name="fname" value="Stale Refsnes"><br>
<button type="submit" >使用编码提交</button>
<button type="submit" formenctype="text/plain">不使用编码提交</button>
</form>
Name: <input type="text" name="fname" value="Stale Refsnes"><br>
<button type="submit" >使用编码提交</button>
<button type="submit" formenctype="text/plain">不使用编码提交</button>
</form>
嘗試一下»
瀏覽器支持
Internet Explorer 10, Firefox, Opera, Chrome, 和Safari 支持formenctype屬性。
注意: Internet Explorer 9及更早IE版本不支持formenctype屬性。
定義和用法
formenctype屬性覆蓋form元素的enctype屬性。
該屬性與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 | 將空格轉換為"+" 符號,但不編碼特殊字符。 |