Skip to main content

checkValidity() / validity

Form constraint validation: the ValidityState flags, checkValidity() and custom messages. Specification: html.spec.whatwg.org/multipage/form-control-infrastructure.html.

Results​

Probed on 2026-10-19 with Node.js v22.23.3.

warpdom 0.1.6​

Supported

5 of 5 checks work.

Web IDL existence (coverage):

Report a wrong result for warpdom

happy-dom 21.0.3​

Partial

4 of 5 checks work.

Web IDL existence (coverage):

  • ValidityState: interface present; 11 of 11 members present.

  • minLength does not apply to a value set by script: minLength 5 and value "a1" set by script leave validity.tooShort false. HTML §4.10.19.4 (the minlength attribute): an element is suffering from being too short only if "its dirty value flag is true, its value was last changed by a user edit (as opposed to a change made by a script), its value is not the empty string, and the length of the element's API value is less than the element's minimum allowed value length".

    • Result: validity.tooShort: expected false, got true
Report a wrong result for happy-dom

jsdom 30.1.3​

Supported

5 of 5 checks work.

Web IDL existence (coverage):

Report a wrong result for jsdom

linkedom 0.18.13​

Missing

Missing: in this engine's window, this does not hold: An <input> has checkValidity() and a validity object.

Web IDL existence (coverage):

Report a wrong result for linkedom

Checks​

Exists when: An <input> has checkValidity() and a validity object.

  • value-missing: An empty required input has validity.valueMissing true; checkValidity() returns false and fires "invalid". (spec)
  • type-mismatch: An email input with value "x" has validity.typeMismatch true. (spec)
  • custom-validity: setCustomValidity("Bad") sets validity.customError and validationMessage "Bad". (spec)
  • pattern-mismatch: pattern="[0-9]+" with value "a1" (set by script) gives validity.patternMismatch true. HTML §4.10.5.3.6 (the pattern attribute): "If the element's value is not the empty string, … and the element has a compiled pattern regular expression but that regular expression does not match the element's value, then the element is suffering from a pattern mismatch"; the pattern is anchored as ^(?:[0-9]+)$, and nothing here depends on how the value was set. (spec)
  • too-short-script-value: minLength does not apply to a value set by script: minLength 5 and value "a1" set by script leave validity.tooShort false. HTML §4.10.19.4 (the minlength attribute): an element is suffering from being too short only if "its dirty value flag is true, its value was last changed by a user edit (as opposed to a change made by a script), its value is not the empty string, and the length of the element's API value is less than the element's minimum allowed value length". (spec)