ElementInternals:validationMessage 属性
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.
ElementInternals 接口的 validationMessage 只读属性返回该元素的验证消息。
值
一个包含此元素验证消息的字符串。
示例
在以下示例中,使用 ElementInternals.setValidity() 设置验证消息,然后使用 validationMessage 返回该消息。
js
this.internals_.setValidity({ valueMissing: true }, "我的消息");
console.log(this.internals_.validationMessage); // "我的消息"
规范
| Specification |
|---|
| HTML> # dom-elementinternals-validationmessage> |
浏览器兼容性
Loading…