Nhập biểu mẫu Gửi
Thí dụ
Tìm hiểu cách dữ liệu biểu mẫu nên được mã hóa trước khi gửi đến máy chủ:
var x = document.getElementById("mySubmit").formEnctype;
Định nghĩa và Cách sử dụng
Thuộc tính formEnctype đặt hoặc trả về giá trị của thuộc tính formenctype của một nút gửi.
Thuộc tính formenctype chỉ định cách dữ liệu biểu mẫu sẽ được mã hóa khi gửi đến máy chủ (chỉ dành cho biểu mẫu có method = "post").
Thuộc tính formenctype ghi đè thuộc tính enctype của phần tử <form>.
Lưu ý: Thuộc tính formenctype là mới cho phần tử <input> với type = "submit" trong HTML5.
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
formEnctype | Yes | 10.0 | Yes | Yes | Yes |
Cú pháp
Trả về thuộc tính formEnctype:
submitObject.formEnctype
Đặt thuộc tính formEnctype:
submitObject.formEnctype = "application/x-www-form-urlencoded,multipart/form-data,text/plain"
Giá trị tài sản
Value | Description |
---|---|
application/x-www-form-urlencoded | Default. All characters are encoded before sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values) |
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 |
Chi tiết kỹ thuật
Giá trị trả lại: | Chuỗi, đại diện cho loại nội dung được sử dụng để gửi biểu mẫu đến máy chủ |
---|
Các ví dụ khác
Thí dụ
Thay đổi giá trị của thuộc tính formenctype của nút gửi thành "application / x-www-form-urlencoded":
document.getElementById("mySubmit").formEnctype = "application/x-www-form-urlencoded";
Các trang liên quan
Tham chiếu HTML: Thuộc tính HTML <input> formenctype
❮ Đối tượng gửi đầu vào