Element: ariaRequired プロパティ

ariaRequiredElement インターフェイスのプロパティで、フォームを送信する前にユーザー入力が必要であることを示す aria-required 属性の値を反映します。

メモ: 使用可能な場合は、HTML の <input> 要素で type="text"<textarea> を使用してください。

以下のいずれかの値を持つ文字列です。

"true"

ユーザーはフォームを送信する前に要素に入力する必要があります。

"false"

フォームを送信するためにユーザー入力は必要ありません。

この例では、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"

仕様書

Specification
Accessible Rich Internet Applications (WAI-ARIA)
# dom-ariamixin-ariarequired

ブラウザーの互換性

BCD tables only load in the browser

関連情報