DOM Properties

ValidityState.valid

True only when none of the validity flags indicate a failure. This is not a server-side authorization or business-rule check. The aggregate flag is useful for status indicators; inspect the individual flags for a useful error message. A barred control may still have a validity state, so valid and willValidate answer different questions. Example result: true.

Formal Syntax & Structure

html syntaxhtml
input.validity.valid

Return Value

boolean

True when no validity constraint flag is set.

Working Example

Example Snippethtml
<input required value="Ada" aria-label="Name"><p>  Result:  <output id="result"></output></p><script>  const result = document.getElementById("result");  (async () => {  const input = document.querySelector("input");  result.textContent = input.validity.valid;  })().catch(error => { result.textContent = "Error: " + error.name; });</script>
HTML Reference