Element: thuộc tính ariaRequired
Baseline
2023
Newly available
Since October 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Thuộc tính ariaRequired của giao diện Element phản chiếu giá trị của thuộc tính aria-required, cho biết người dùng cần nhập liệu vào phần tử trước khi biểu mẫu có thể được gửi.
Note:
Khi có thể, hãy sử dụng phần tử HTML <input> với type="text" hoặc <textarea> vì chúng có ngữ nghĩa tích hợp sẵn và không yêu cầu thuộc tính ARIA.
Giá trị
Một chuỗi với một trong các giá trị sau:
Ví dụ
Trong ví dụ này, thuộc tính aria-required trên phần tử có ID txtBoxInput được đặt thành "true" cho biết đầu vào này phải được hoàn thành. Sử dụng ariaRequired chúng ta cập nhật giá trị thành "false".
html
<div id="txtboxMultilineLabel">Enter the tags for the article</div>
<div
role="textbox"
id="txtBoxInput"
contenteditable="true"
aria-multiline="true"
aria-labelledby="txtboxMultilineLabel"
aria-required="true"></div>
js
let el = document.getElementById("txtBoxInput");
console.log(el.ariaRequired); // "true"
el.ariaRequired = "false";
console.log(el.ariaRequired); // "false"
Đặc tả kỹ thuật
| Specification |
|---|
| Accessible Rich Internet Applications (WAI-ARIA)> # dom-ariamixin-ariarequired> |