Input Submit formEnctype Attribute
Definition and Usage
formEnctype
Set or return 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 type="submit" <input> element in HTML5.
Lihat juga:
HTML Reference Manual:Atribut formenctype <input> HTML
Example
Contoh 1
Cari tahu bagaimana mengkodek data formulir sebelum disubmit ke server:
var x = document.getElementById("mySubmit").formEnctype;
Contoh 2
Ubah nilai atribut formenctype tombol pengiriman menjadi "application/x-www-form-urlencoded":
document.getElementById("mySubmit").formEnctype = "application/x-www-form-urlencoded";
Syntax
Return formEnctype attribute:
submitObject.formEnctype
Setel atribut formEnctype:
submitObject.formEnctype = "application/x-www-form-urlencoded,multipart/form-data,text/plain"
Attribute Value
Value | Description |
---|---|
application/x-www-form-urlencoded | Default. Semua karakter dienkodifikasi sebelum dikirim (spasi diubah menjadi simbol "+", karakter khusus diubah menjadi nilai HEX ASCII). |
multipart/form-data | Tidak mengodek karakter. Saat Anda menggunakan formulir dengan kontrol unggah berkas, nilai ini diperlukan. |
text/plain | Spasi diubah menjadi simbol "+", tetapi karakter khusus tidak dienkodifikasi. |
Detil Teknologi
Nilai kembalian: | Nilai string yang menunjukkan jenis konten yang digunakan untuk mengirimkan formulir ke server. |
---|
Dukungan Browser
Angka di tabel menunjukkan versi browser pertama yang mendukung atribut ini.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Dukungan | 10.0 | Dukungan | Dukungan | Dukungan |