此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。

View in English Always switch to English

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 ⁨2015年7月⁩.

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

語法

js
selectElt.setCustomValidity(string);

參數

  • stringDOMString,代表錯誤訊息。

規範

Specification
HTML
# dom-cva-setcustomvalidity-dev

瀏覽器相容性

參見