HTML oninvalid Attribute
Example
<form action="action.php">
Name: <input type="text" oninvalid="alert('You must enter this field!');" name="fname" required>
<input type="submit" value="Submit">
</form>
Meaning
The oninvalid attribute fires when a submittable element do not satisfy their constraints during form validation.
Standard Syntax
<element oninvalid="script">
Applies to:
The oninvalid attribute can be used on the following element:
| Element | Attribute |
|---|---|
| All HTML elements. | oninvalid |
Advertisement
Attribute Values
| Value | Description |
|---|---|
| script | Specifies the script to be run on oninvalid |