Constraint validation APIBaseline · Widely available
Methods that validate form controls before submission, such as checkValidity(), reportValidity() and setCustomValidity().
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Dec 11, 2018. Widely available since Jun 11, 2021.
Browser support
DesktopChrome
1–39Not supported
40+Supportedsince Jan 21, 2015
Current: 155Edge
12–17Not supported
18+Supportedsince Oct 2, 2018
Current: 154Firefox
1–50Not supported
51+Supportedsince Jan 24, 2017
Current: 157Safari
1–10Not supported
10.1+Supportedsince Mar 27, 2017
Current: 27MobileChrome Android
18–39Not supported
40+Supportedsince Jan 21, 2015
Current: 155Firefox Android
4–63Not supported
64+Supportedsince Dec 11, 2018
Current: 157Safari iOS
1–10Not supported
10.3+Supportedsince Mar 27, 2017
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: checkValidity.
Feature detection
JS · check before using
if ("HTMLButtonElement" in globalThis && "validationMessage" in HTMLButtonElement.prototype) {
// HTMLButtonElement.validationMessage is available
}Sub-features
Support for each part of the feature (56). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| HTMLButtonElement.checkValidity | 4 | 12 | 4 | 5 | 18 | 4 | 5 |
| HTMLButtonElement.reportValidity | 40 | 17 | 49 | 10.1 | 40 | 64 | 10.3 |
| HTMLButtonElement.setCustomValidity | 4 | 12 | 4 | 5 | 18 | 4 | 5 |
| HTMLButtonElement.validationMessage | 5 | 12 | 4 | 5 | 18 | 4 | 4 |
| HTMLButtonElement.validity | 4 | 12 | 4 | 5 | 18 | 4 | 4 |
| HTMLButtonElement.willValidate | 2 | 12 | 4 | 4 | 18 | 4 | 3 |
| HTMLFieldSetElement.checkValidity | 4 | 12 | 4 | 5 | 18 | 4 | 5 |
| HTMLFieldSetElement.reportValidity | 40 | 17 | 49 | 10.1 | 40 | 64 | 10.3 |
| HTMLFieldSetElement.setCustomValidity | 4 | 12 | 4 | 5 | 18 | 4 | 5 |
| HTMLFieldSetElement.validationMessage | 5 | 12 | 4 | 5 | 18 | 4 | 4 |
| HTMLFieldSetElement.validity | 4 | 12 | 4 | 5 | 18 | 4 | 4 |
| HTMLFieldSetElement.willValidate | 2 | 12 | 4 | 4 | 18 | 4 | 3 |
| HTMLFormElement.checkValidity | 4 | 12 | 4 | 5 | 18 | 4 | 4 |
| HTMLFormElement.reportValidity | 40 | 17 | 49 | 10.1 | 40 | 49 | 10.3 |
| HTMLInputElement.checkValidity | 4 | 12 | 4 | 5 | 18 | 4 | 4 |
| HTMLInputElement.reportValidity | 40 | 17 | 49 | 10.1 | 40 | 64 | 10.3 |
| HTMLInputElement.setCustomValidity | 4 | 12 | 4 | 5 | 18 | 4 | 4 |
| HTMLInputElement.validationMessage | 5 | 12 | 4 | 5 | 18 | 4 | 4 |
| HTMLInputElement.validity | 4 | 12 | 4 | 5 | 18 | 4 | 4 |
| HTMLInputElement.willValidate | 2 | 12 | 4 | 4 | 18 | 4 | 3 |