Check Validity
Validating input fields is possible but it doesn't come from a black sorcery.
It is possible through a specific JS function that every input DOM element has. The checkValidity() function. This functions checks for all the criteria an input field contains and returns a boolean value (true if the data is valid, false if not).
Anytime this function returns a false value, triggers the 'invalid' event on the field.
Let's see an example of this.