HTMLSelectElement.setCustomValidity()

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.

HTMLSelectElement.setCustomValidity() 方法可為指定的元素設定自定義檢核訊息。使用空字串表示元素沒有發生違反自定檢核條件的錯誤。

語法

js
selectElt.setCustomValidity(string);

參數

  • stringDOMString,代表錯誤訊息。

規範

Specification
HTML
# dom-cva-setcustomvalidity-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
setCustomValidity

Legend

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

Full support
Full support
See implementation notes.

參見