constraint-validation-example

Expand History Expand History
Collapse History Collapse History

Dynamically disable invalid form submit buttons

When an invalid event fires, set all of element’s related <form> submit buttons to [disabled]. In this case, a “submit” button is an <input type="submit">, a <button type="submit">, or a <button> element that does not declare a [type] attribute.

When the blur event fires for a valid field, update the <form> element’s submit buttons based on whether or not all of the <form> s fields are valid. In this case, a form is “valid” if every element’s ValidityState.valid == true. This property is dynamically updated by the browser outside of the checkValidity() and reportValidity() interface updating methods.

Similarly, when an input event fires, update the <form> element’s submit buttons based on its “validity”.