如果中添加的字段值無效,則會觸發oninvalid事件。如果用戶在提交前忘記填寫表單,請添加一條消息。
示例
您可以嘗試運行以下代碼來了解如何實現oninvalid ?JavaScript 中的事件。
<!DOCTYPE html>
<html>
<body>
<script>
function resetFunct() {
alert("The form was reset");
}
</script>
<form>
Enter Name: <input type="text"
required oninvalid = "alert('Fill the form before submitting!');" > <br>
Enter birth month: <input type= "text"> <br>
<input type = "submit">
<input type = "reset">
</form>
</body>
</html>
登錄后復制
以上就是在JavaScript中,"oninvalid"事件的用途是什么?的詳細內容,更多請關注www.92cms.cn其它相關文章!






