DOM Properties

ValidityState.tooLong

Reports a user-edited value exceeding maxlength measured in UTF-16 code units. Browsers may prevent extra typing; setting value in script alone does not trigger this length constraint. The example demonstrates that distinction. Example result: false.

Formal Syntax & Structure

html syntaxhtml
input.validity.tooLong

Return Value

boolean

Read-only constraint flag.

Working Example

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