【JS】登陆验证

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

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


打赏
分享给朋友:

相关文章

【JS】For语句3个月前 (03-17)
【JS】关于continue3个月前 (03-24)
【JS】循环嵌套3个月前 (03-24)
【JS】倒三角形3个月前 (03-24)
【JS】筛选数组3个月前 (03-31)