HTMLSelectElement:checkValidity() 方法

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.

io error: No such file or directory (os error 2) (/home/runner/work/yari/yari/mdn/translated-content/files/zh-cn/web/api/htmlselectelement/index.md)

HTMLSelectElement.checkValidity() 会检查元素是否有任何输入约束条件,并且检查值是否符合约束条件。如果值是不符合约束条件的,浏览器就会在该元素上触发一个可以撤销的 invalid 事件,然后返回 false

语法

js
checkValidity()

参数

返回值

如果元素的值满足约束条件,返回 true,否则返回 false

规范

Specification
HTML Standard
# dom-cva-checkvalidity-dev

浏览器兼容性

BCD tables only load in the browser

参见