The oninvalid event occurs when a submittable input element is invalid like the input field is invalid if the required attribute is set and the field is empty.