HTMLFormElement: checkValidity() メソッド
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.
checkValidity()
は HTMLFormElement
インターフェイスのメソッドで、関連付けられたコントロールすべてが適用された制約検証ルールを満たしているかどうかを示す論理値を返します。 このメソッドは、値が不正な要素にそれぞれ対して invalid
イベントを発行しますが、このフォーム要素自体には発行しません。 checkValidity()
には既定でブラウザーの動作が設定されていないため、この invalid
イベントをキャンセルしても効果はありません。
構文
js
checkValidity()
引数
なし。
返値
関連付けられたフォームコントロールの値に妥当性の問題がなければ true
を返し、そうでなければ false
を返します。
例
次の例では、checkValidity()
を呼び出すと、true
または false
を返します。
js
const element = document.getElementById("myForm");
console.log(element.checkValidity());
仕様書
Specification |
---|
HTML # dom-form-checkvalidity-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
checkValidity |
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.