The invalid event fires when a submittable element has been checked for validity and doesn't satisfy its constraints.

Interface Event
Bubbles No
Cancelable Yes
Targets Element
Default Action Varies (can prevent form from being submitted)

This event can be useful for displaying a summary of the problems with a form on submission.  When a form is submitted, invalid events are fired at each form control that is invalid, and then at the form element itself. The validity of submittable elements is checked before submitting their owner <form>, or after the checkValidity() method of the element or its owner <form> is called. It is not checked on blur.


If a form is submitted with an invalid value, the submittable elements are checked and, if an error is found, the invalid event will fire on the invalid element. In this example, when an invalid event fires because of an invalid value in the input, the invalid value is logged.


<form action="#">
    <li><label>Enter an integer between 1 and 10: <input type="number" min="0" max="10" required></label></li>
    <li><input type="submit" value="submit"></li>
</form><p id="log"></p>


const input = document.querySelector('input');
const log = document.getElementById('log');

input.addEventListener('invalid', logValue);

function logValue(e) {
  log.textContent += e.srcElement.value;



Specification Status Comment
HTML Living Standard
The definition of 'Invalid event' in that specification.
Living Standard  
HTML 5.1
The definition of 'Invalid event' in that specification.
The definition of 'Invalid event' in that specification.

See also

Document Tags and Contributors

Last updated by: irenesmith,