ボタンformEnctypeプロパティ
例
サーバーに送信する前にフォームデータをエンコードする方法を返します。
var x = document.getElementById("myBtn").formEnctype;
定義と使用法
formEnctypeプロパティは、ボタンのformenctype属性の値を設定または返します。
formenctype属性は、フォームデータをサーバーに送信する前にエンコードする方法を指定します。この属性は、フォームのenctype属性をオーバーライドします。
formenctype属性は、type = "submit"のボタンにのみ使用されます。
注: formenctype属性は、HTML5の<button>要素の新機能です。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
formEnctype | Yes | 10.0 | Yes | Yes | Yes |
構文
formEnctypeプロパティを返します。
buttonObject.formEnctype
formEnctypeプロパティを設定します。
buttonObject.formEnctype = "application/x-www-form-urlencoded,multipart/form-data,text/plain"
プロパティ値
Value | Description |
---|---|
application/x-www-form-urlencoded | All characters are encoded before sent (this is default) |
multipart/form-data | No characters are encoded. This value is required when you are using forms that have a file upload control |
text/plain | Spaces are converted to "+" symbols, but no special characters are encoded |
技術的な詳細
戻り値: | フォームをサーバーに送信するために使用されるコンテンツのタイプを表す文字列 |
---|
その他の例
例
ボタンのformenctype属性の値を「text / plain」から「application / x-www-form-urlencoded」に変更します。
document.getElementById("myBtn").formEnctype = "application/x-www-form-urlencoded";
例
formEnctypeプロパティを返す別の例:
var x =
document.getElementById("myBtn").formEnctype;
関連ページ
HTMLリファレンス:HTML <button> formenctype属性
❮ボタンオブジェクト