invalid | oninvalid event
Provides specified alert text if an input element is invalid.
![]() |
Syntax
| HTML Attribute | <element oninvalid = "handler(event)"> |
|---|---|
| Event Property | object.oninvalid = handler; |
| attachEvent Method | object.attachEvent("oninvalid", handler) |
| addEventListener Method | object.addEventListener("invalid", handler, useCapture) |
Event information
| Synchronous | No |
|---|---|
| Bubbles | No |
| Cancelable | Yes |
Event handler parameters
- pEvtObj [in]
-
Type: IHTMLEventObj
Standards information
Examples
The following snippet is an example of oninvalid being used to throw an alert if a user submits no text into a required text field.
<html> <body> <form> Password: <input type="text" oninvalid="alert('Please enter a password');" required> <input type="submit" value="Submit"> </form> </body> </html>
See also
- input
- input type=button
- input type=checkbox
- input type=date
- input type=datetime-local
- input type=email
- input type=file
- input type=hidden
- input type=image
- input type=month
- input type=number
- input type=password
- input type=radio
- input type=range
- input type=reset
- input type=search
- input type=submit
- input type=tel
- input type=text
- input type=time
- input type=url
- input type=week
Show:
