revision:
The oninvalid event occurs when a submittable <input> element is invalid.
Supported HTML tags: <input>
<element oninvalid="script"></element>
script: the script to be run on oninvalid.
If you click submit, without filling out the text field, an alert message will occur.
<form style="margin-left:3vw;" action="/action_page.php" method="get"> <p class="spec"> Name: <input type="text" oninvalid="alert('You must fill out the form!');" name="fname" required></p> <input style="margin-left:3vw;" type="submit" value="Submit"> </form> <p class="spec">If you click submit, without filling out the text field, an alert message will occur.</p>
If you submit the input field with less than 6 characters, an alert message will occur.
<form style="margin-left:3vw;" action="/action_page.php" method="get"> <p class="spec">Name: <input type="text" oninvalid="alert('Must contain 6 or more characters');" name="fname" pattern=".{6,}"></p> <input class="spec" type="submit" value="Submit"> </form> <p class="spec">If you submit the input field with less than 6 characters, an alert message will occur.</p>