Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HTMLFormElement
  4. checkValidity()

HTMLFormElement: checkValidity() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

ThecheckValidity() method of theHTMLFormElement interface returns a boolean value which indicates if all associated controls meet anyconstraint validation rules applied to them. The method also fires aninvalid event on each invalid element, but not on the form element itself. Because there's no default browser behavior forcheckValidity(), canceling thisinvalid event has no effect.

Note:The:valid and:invalid CSS pseudo-classes are applied to<form> elements based on the validity of its owned form controls, not the validity of the<form> element itself.

Syntax

js
checkValidity()

Parameters

None.

Return value

Returnstrue if the associated controls' values have no validity problems; otherwise, returnsfalse.

Examples

In the following example, callingcheckValidity() would returntrue if orfalse.

js
const element = document.getElementById("myForm");console.log(element.checkValidity());

Specifications

Specification
HTML
# dom-form-checkvalidity-dev

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp