JavaScript DOM操作案例判断密码长度

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<input type="password" value="" id="pw"/>
<script src="common.js"></script>
<script>
    //获取文本框
    my$("pw").onblur = function () {
        //判断密码长度
        if (this.value.length >= 6 && this.value.length <= 10) {
            this.style.backgroundColor = "red";
        } else {
            this.style.backgroundColor = "green";
        }
    };
</script>
</body>
</html>

 

posted @ 2018-07-23 21:39  {颜逸}  阅读(842)  评论(0编辑  收藏  举报