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

validationMessageHTMLTextAreaElement インターフェイスの読み取り専用プロパティで、この <textarea> コントロールが満たしていない検証制約をを記述したローカライズされたメッセージを表す文字列を(もしあれば)返します。 コントロールが制約検証の対象ではない場合(HTMLTextAreaElement.willValidatefalse の場合)、または制約を満たしている場合は、空文字列が返されます。

もし、この <textarea> 要素が制約検証の対象(willValidatetrue)であり、制約が満たされていない場合(HTMLInputElement.validity オブジェクトの valid プロパティが false)、値は検証中にユーザーに表示されるエラーメッセージとなります。

文字列です。

js
const textarea = document.getElementById("myTextArea");
const errorMessage = textarea.validationMessage;

仕様書

Specification
HTML
# dom-cva-validationmessage-dev

ブラウザーの互換性

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
validationMessage

Legend

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

Full support
Full support

関連情報