![]() |
Definition and UsageThe oninvalid event occurs when a submittable <input> element is invalid. For example, the input field is invalid if the required attribute is set and the field is empty (the required attribute specifies that the input field must be filled out before submitting the form). Applies toThe oninvalid attribute is part of the Event Attributes, and can be used on any HTML elements.
Browser SupportThe numbers in the table specify the first browser version that fully supports the event attribute. |
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php" method="get">
Name: <input type="text" oninvalid="alert('You must fill out the form!');" name="fname" required>
<input type="submit" value="Submit">
</form>
<p>If you click submit, without filling out the text field, an alert message will occur.</p>
<p><strong>Note:</strong> The oninvalid event is not supported in Safari.</p>
</body>
</html>
html oninvalid attribute |
How to add HTML oninvalid Attribute | HTML Attribute |
Read Full: | HTML Attribute |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Attribute |
Uploaded by: | Admin |
Views: | 131 |
Reffered: https://www.w3schools.com/tags/att_oninvalid.asp