Element: ariaRequired プロパティ
Baseline
広く利用可能
この機能は広く実装されており、多くのバージョンの端末やブラウザーで動作します。2023年10月以降、すべてのブラウザーで利用可能です。
ariaRequired は Element インターフェイスのプロパティで、フォームを送信する前にユーザー入力が必要であることを示す aria-required 属性の値を反映します。
メモ:
使用可能な場合は、HTML の <input> 要素で type="text" と <textarea> を使用してください。
値
以下のいずれかの値を持つ文字列です。
例
この例では、txtBoxInput という ID を持つ要素の aria-required 属性は "true" に設定されており、この入力が完了しなければならないことを示しています。ariaRequired を使用して値を "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"
仕様書
| 仕様書 |
|---|
| Accessible Rich Internet Applications (WAI-ARIA)> # dom-ariamixin-ariarequired> |