Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

ValidityState.valid — aggregate control validity

ValidityState.valid is a read-only boolean property: it is true when none of the control's validation error flags are set.

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

element.validity.valid

ValidityState.valid, accessed as element.validity.valid, is true when every other error flag in ValidityState is false. This is a browser API defined by the HTML Standard, not a feature of a particular ECMAScript edition.

The validity object is live. In the example, the empty required input is invalid; entering Ada removes the missing-value error. A nonempty setCustomValidity() message sets a custom error; setCustomValidity('') clears it.

Reading valid neither displays a message nor fires invalid. It also does not mean the control participates in validation: willValidate indicates that eligibility. checkValidity() accounts for eligibility, while reportValidity() can additionally show the problem.

Examples

const input = document.createElement('input');
input.required = true;
const state = input.validity;
console.log(state.valid);
input.value = 'Ada';
console.log(state.valid);
input.setCustomValidity('Rejected');
console.log(state.valid);
input.setCustomValidity('');
console.log(state.valid);

Result

false
true
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.

Sources