Element: 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.

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

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
ariaRequired

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報