DOM Properties
ValidityState.patternMismatch
True when a nonempty value fails the applicable pattern constraint. The regular expression must match the entire value; invalid patterns do not impose a constraint. Example result: true.
Formal Syntax & Structure
html syntaxhtml
input.validity.patternMismatchReturn Value
boolean
Read-only constraint flag.
Working Example
Example Snippethtml
<input pattern="[A-Z]{2}" value="ab" aria-label="Code"><p> Result: <output id="result"></output></p><script> const result = document.getElementById("result"); (async () => { const input = document.querySelector("input"); result.textContent = input.validity.patternMismatch; })().catch(error => { result.textContent = "Error: " + error.name; });</script>