HTMLFormElement: reportValidity() method

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("HTML DOM")}}

The **reportValidity()** method of the {{domxref("HTMLFormElement")}} interface performs the same validity checking steps as the {{domxref("HTMLFormElement.checkValidity", "checkValidity()")}} method. In addition, for each {{domxref("HTMLElement/invalid_event", "invalid")}} event that was fired and not canceled, the browser displays the problem to the user.

Syntax

js-nolint
reportValidity()

Parameters

None.

Return value

Returns true if the associated controls' values have no validity problems; otherwise, returns false.

Example

js
document.forms["my-form"].addEventListener("submit", () => {
  document.forms["my-form"].reportValidity();
});

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also