HTML oninvalid Attribute

❮ HTML Attributes

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">



Browser Support




Status




Applies to:

The oninvalid attribute can be used on the following element:

Element Attribute
All HTML elements. oninvalid






Attribute Values

Value Description
script Specifies the script to be run on oninvalid
❮ HTML Attributes