HTMLFormElement: reportValidity() メソッド
Baseline 2023
Newly available
Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
HTMLFormElement.reportValidity()
メソッドは、この要素の子コントロールが制約検証を満たしていれば true
を返します。
false
が返された場合、キャンセル可能な
invalid
イベントが無効な子要素それぞれについて発行され、ユーザーに検証の問題を報告します。
構文
js
reportValidity()
返値
true
または false
例
js
document.forms["myform"].addEventListener(
"submit",
() => {
document.forms["myform"].reportValidity();
},
false,
);
仕様書
Specification |
---|
HTML Standard # dom-cva-reportvalidity-dev |
ブラウザーの互換性
BCD tables only load in the browser