Movatterモバイル変換


[0]ホーム

URL:


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

HTMLTextAreaElement: 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 theHTMLTextAreaElement interface returns a boolean value which indicates if the element meets anyconstraint validation rules applied to it. If false, the method also fires aninvalid event on the element. Because there's no default browser behavior forcheckValidity(), canceling thisinvalid event has no effect.

Note:An HTML<textarea> element with a non-nullvalidationMessage is considered invalid, will match the CSS:invalid pseudo-class, and will causecheckValidity() to return false. Use theHTMLTextAreaElement.setCustomValidity() method to set theHTMLTextAreaElement.validationMessage to the empty string to set thevalidity state to be valid.

Syntax

js
checkValidity()

Parameters

None.

Return value

Returnstrue if the element's value has no validity problems; otherwise, returnsfalse.

Examples

In the following example, callingcheckValidity() returns eithertrue orfalse.

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

Specifications

Specification
HTML
# dom-cva-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