How to use HTML form.checkValidity() || how is chekValidity() method works

checkValidity() is a HTML5 method and

When the checkValidity() method is invoked, if the element is a candidate for constraint validation and does not satisfy its constraints, the user agent must fire a simple event named invalid that is cancelable (but in this case has no default action) at the element and return false. Otherwise, it must only return true without doing anything else.