What is the usage of oninvalid event in JavaScript?

HTMLJavascriptProgramming Scripts

The oninvalid event is triggered if the field value added in <input> is invalid. Add a message if the user forgets to fill the form before submission.


You can try to run the following code to learn how to implement oninvalid event in JavaScript.

<!DOCTYPE html>
         function resetFunct() {
            alert("The form was reset");
         Enter Name: <input type="text"
         required oninvalid = "alert('Fill the form before submitting!');" >  <br>
         Enter birth month: <input type=  "text"> <br>
         <input type = "submit">
         <input type = "reset">
Updated on 22-May-2020 11:17:18