HTMLSelectElement: thuộc tính required
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thuộc tính required của giao diện HTMLSelectElement chỉ định rằng người dùng phải chọn một tùy chọn có giá trị chuỗi không rỗng trước khi gửi biểu mẫu. Nó phản ánh thuộc tính required của phần tử <select>.
Giá trị
Một giá trị boolean.
Ví dụ
js
const selectElement = document.getElementById("fruits");
console.log(selectElement.required);
Đặc tả kỹ thuật
| Specification |
|---|
| HTML> # dom-select-required> |
Tương thích trình duyệt
Xem thêm
<select>HTMLSelectElement.validity:requiredpseudo-class