DOM Properties

ElementInternals.willValidate

Build a form with the HTML form generator

Indicates whether this form-associated element is a candidate for constraint validation. A disabled control is barred from validation. This is a participation test, not a test of whether the current value is correct. A form-associated custom control can have willValidate true and validity.valid false at the same time. Read validity or call checkValidity for the latter question. Example result: true.

Formal Syntax & Structure

html syntaxhtml
internals.willValidate

Return Value

boolean

True if the custom element is a candidate for constraint validation.

Working Example

Example Snippethtml
<form id="demo-form">  <demo-field name="city"></demo-field></form><p>  Result:  <output id="result"></output></p><script>  const result = document.getElementById("result");  (async () => {  class DemoField extends HTMLElement { static formAssociated = true; constructor() { super(); this.internals = this.attachInternals(); } }  customElements.define("demo-field", DemoField);  const field = document.querySelector("demo-field"); const internals = field.internals;  result.textContent = internals.willValidate;  })().catch(error => { result.textContent = "Error: " + error.name; });</script>
HTML Reference