HTMLInputElement: validationMessage プロパティ
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.
validationMessage
は HTMLInputElement
インターフェイスの読み取り専用プロパティで、(もしあれば)この <input>
コントロールが満たしていない検証制約を記述したローカライズされたメッセージを表す文字列を返します。
この <input>
要素が制約検証の対象ではない場合(HTMLInputElement.willValidate
が false
の場合)、または制約を満たしている場合は空文字列 (""
) となります。
もし、この要素が制約の検証対象(willValidate
が true
)であり、制約が満たされていない場合(HTMLInputElement.validity
オブジェクトの valid
プロパティが false
)、値は検証中にユーザーに表示されるエラーメッセージとなります。
値
文字列です。
例
js
const input = document.getElementById("myInput");
const errorMessage = input.validationMessage;
仕様書
Specification |
---|
HTML # dom-cva-validationmessage-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
validationMessage |
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.