<html>
<body>
<form action="/demo/html/action_page.php" method="get">
Name: <input type="text" oninvalid="alert('You must fill out the form!');" name="fname" required>
<input type="submit" value="Submit">
</form>
<p>如果您点击提交,而不填写文本字段,将出现警告消息。</p>
<p><b>注释:</b>Internet Explorer 9 及更早版本或 Safari 不支持 oninvalid 事件。</p>
</body>
</html>