The HTMLSelectElement.setCustomValidity()
method sets the custom validity message for the selection element to the specified message. Use the empty string to indicate that the element does not have a custom validity error.
HTMLSelectElement: setCustomValidity() method
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.
Syntax
js
setCustomValidity(string)
Parameters
-
string
is the string containing the error message.
Return value
None (undefined
).
Specifications
Specification |
---|
HTML Standard # dom-cva-setcustomvalidity-dev |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | ||
setCustomValidity |
4This method only updates the validation error popup, not the tooltip that appears when hovering the mouse over the element, see bug 828757. |
12 | 4 | ≤12.1 | 5 | 18This method only updates the validation error popup, not the tooltip that appears when hovering the mouse over the element, see bug 828757. |
4 | ≤12.1 | 4 | 1.0This method only updates the validation error popup, not the tooltip that appears when hovering the mouse over the element, see bug 828757. |
≤37 |
See also
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/setCustomValidity