A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/checkValidity below:

ElementInternals: checkValidity() method - Web APIs

ElementInternals: checkValidity() method

Baseline 2023

Newly available

The checkValidity() method of the ElementInternals interface checks if the element meets any constraint validation rules applied to it.

If checkValidity returns false then a cancelable invalid event is fired on the element.

Syntax Parameters

None.

Return value

A boolean value, true if the element meets all validation constraints.

Exceptions
NotSupportedError DOMException

Thrown if the element does not have its formAssociated property set to true.

Examples

In the following example ElementInternals.setValidity() is used to indicate that the element does not meet validation rules. Calling checkValidity() returns false. After calling setValidity again, this time indicating that all rules are marked false, checkValidity() returns true.

let element = document.getElementById("join-checkbox");
element.internals_.setValidity({ valueMissing: true }, "my message");
console.log(element.internals_.checkValidity()); // false
element.internals_.setValidity({});
console.log(element.internals_.checkValidity()); // true
Specifications Browser compatibility

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3