ElementInternals: validationMessage property
Baseline 2023Newly available
Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The validationMessage
read-only property of the ElementInternals
interface returns the validation message for the element.
Value
A string containing the validation message of this element.
Examples
In the following example the validation message is set with ElementInternals.setValidity()
, and then returned with validationMessage
.
js
this.internals_.setValidity({ valueMissing: true }, "my message");
console.log(this.internals_.validationMessage); // "my message"
Specifications
Specification |
---|
HTML Standard # dom-elementinternals-validationmessage |
Browser compatibility
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.