【JS】登陆验证

Osinghong2个月前 (04-28)成果展示70

使用了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>


打赏
分享给朋友:

相关文章

【H5】ul,li练习7个月前 (12-04)
【H5】页面布局练习7个月前 (12-05)
【JS】三元表达式4个月前 (03-17)
【JS】水果查询4个月前 (03-17)
【JS】For语句进阶3个月前 (03-24)