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

<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<input type="password" value="" />
<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>