CKTIS / JavaScript
HTMLFormElement.reportValidity() — validate a form with user feedback
HTMLFormElement.reportValidity() checks validation constraints on controls associated with a form and can report errors to the user. It returns a boolean and does not itself submit the form.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
form.reportValidity()HTMLFormElement.reportValidity is a form-interface method defined by the HTML Living Standard, not ECMAScript. Calling form.reportValidity() takes no arguments and synchronously returns true when all controls eligible for validation are valid, or false when at least one is invalid.
The method runs interactive constraint validation for constraints such as required. It fires invalid events at invalid controls. The browser can report errors whose handling was not canceled; message appearance and wording depend on the browser. Calling event.preventDefault() in an invalid handler suppresses native reporting of that error but does not change the false result.
Unlike reportValidity(), checkValidity() checks constraints without interactive error reporting, although it also fires invalid. Neither method submits the form. Controls disabled through disabled are excluded from validation; client-side validation does not replace server-side data checks.
This is a browser API: the presence of Node 24 does not establish availability. In the target environment, check typeof HTMLFormElement !== 'undefined' && typeof HTMLFormElement.prototype.reportValidity === 'function'. The example deliberately cancels invalid to check boolean results without depending on validation-message UI.
Examples
(() => {
const form = document.createElement('form');
const input = document.createElement('input');
input.required = true;
input.setAttribute('aria-label', 'Name');
form.append(input);
document.body.append(form);
// Suppress native validation UI for deterministic console checks.
input.addEventListener('invalid', event => event.preventDefault());
console.log(form.reportValidity());
input.value = 'Ada';
console.log(form.reportValidity());
form.remove();
})();Result
false true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.