HTMLSelectElement: validity プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since December 2018.
validity
は HTMLSelectElement
インターフェイスの読み取り専用プロパティは、この要素の有効状態を表す ValidityState
オブジェクトを返します。
値
ValidityState
オブジェクトです。
例
次の例では、選択要素の妥当性状態を取得し、妥当でない場合は処理します。
js
const select = document.getElementById("mySelect");
const validityState = select.validity;
if (!validityState.valid) {
// それぞれの妥当性状態を検査
}
仕様書
Specification |
---|
HTML # the-constraint-validation-api:dom-cva-validity |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
validity |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.