HTML에서 요소가 유효하지 않을 때 스크립트를 실행하려면 oninvalid를 사용하세요. 속성.
예시
다음 코드를 실행하여 무효를 구현할 수 있습니다. 속성.
<!DOCTYPE html>
<html>
<head>
<title>HTML oninvalid attribute</title>
</head>
<body>
<h2>ID</h2>
<form action = "/new.php">
<input type = "text" placeholder = "Student ID" name = "sname" oninvalid = "alert('Fill it first!')" required /><br>
<input type = "submit" value = "Submit">
</form>
</body>
</html>