【JS】登陆验证
使用了DOM
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>d24c04429</title>
</head>
<body>
<h1>学号验证</h1>
<p>请输入您的学号:</p>
<input type="text" id="studentId" placeholder="学号">
<button id="validateBtn">验证</button>
<script>
document.getElementById('validateBtn').addEventListener('click', function () {
var studentId = document.getElementById('studentId').value;
if (studentId.length !== 8) {
alert("学号长度错误");
} else {
alert("学号验证通过");
}
});
</script>
</body>
</html>