Javascript examples for DOM Event:Element Event Attribute
The oninvalid event occurs when a submittable <input> element is invalid.
Bubbles | No |
---|---|
Cancelable | Yes |
Supported HTML tags: | <input> |
<!DOCTYPE html> <html> <body> <form action="/action_page.php" method="get"> Name: <input type="text" id="myInput" name="fname" required> <input type="submit" value="Submit"> </form>/*from w w w . j a v a 2 s .co m*/ <script> document.getElementById("myInput").oninvalid = function() {myFunction()}; function myFunction() { console.log("You must fill out the form!"); } </script> </body> </html>