Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

invalid | oninvalid event

Provides specified alert text if an input element is invalid.

HTML5 A vocabulary and associated APIs for HTML and XHTML, 6.1.5

 

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

SynchronousNo
BubblesNo
CancelableYes

 

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:
© 2017 Microsoft