润宇betvictor85
业务介绍:betvictor xin1946betvictor85公司、betvictor85开发、betvictor85定制、betvictor85外包
betvictor85
方案
文章

betvictor85|betvictor xin1946|伟德国际 伟德官网

发布时间:2017/9/4  浏览次数:2次  字体【    】

<form name="form1" action="">
    密码:<input type="password" size="8" onkeyup="pwStrength(this.value)" onblur="pwStrength(this.value)">
    <br>
    密码强度:
    <table width="220px" border="1" cellspacing="0" cellpadding="1" bordercolor="#eeeeee" height="22px">
        <tr align="center" bgcolor="#f5f5f5">
            <td width="33%" id="strength_L">弱</td>
            <td width="33%" id="strength_M">中</td>
            <td width="33%" id="strength_H">强</td>
        </tr>
    </table>
</form>

function pwdStrength(pwd) {
    O_color = "#eeeeee";
    L_color = "#FF0000";
    M_color = "#FF9900";
    H_color = "#33CC00";
    var level = 0, strength = "O";
    if (pwd == null || pwd == '') {
        strength = "O";
        Lcolor = Mcolor = Hcolor = O_color;
    }
    else {
        var mode = 0;
        if (pwd.length <= 4)
            mode = 0;
        else {
            for (i = 0; i < pwd.length; i++) {
                var charMode, charCode;
                charCode = pwd.charCodeAt(i);
                // 判断输入密码的类型
                if (charCode >= 48 && charCode <= 57) //数字 
                    charMode = 1;
                else if (charCode >= 65 && charCode <= 90) //大写 
                    charMode = 2;
                else if (charCode >= 97 && charCode <= 122) //小写 
                    charMode = 4;
                else
                    charMode = 8;
                mode |= charMode;
            }
            // 计算密码模式
            level = 0;
            for (i = 0; i < 4; i++) {
                if (mode & 1)
                    level++;
                mode >>>= 1;
            }
        }
        switch (level) {
            case 0:
                strength = "O";
                Lcolor = Mcolor = Hcolor = O_color;
                break;
            case 1:
                strength = "L";
                Lcolor = L_color;
                Mcolor = Hcolor = O_color;
                break;
            case 2:
                strength = "M";
                Lcolor = Mcolor = M_color;
                Hcolor = O_color;
                break;
            default:
                strength = "H";
                Lcolor = Mcolor = Hcolor = H_color;
                break;
        }
    }
    document.getElementById("strength_L").style.background = Lcolor;
    document.getElementById("strength_M").style.background = Mcolor;
    document.getElementById("strength_H").style.background = Hcolor;
    return strength;
}

 
西部IT网合作伙伴
合作伙伴
© 版权所有:betvictor xin1946润宇betvictor85科技有限公司 
公司地址:betvictor xin1946市碑林区 联系电话:029-87878512 手机:13468700578 联系人:李先生
Copyright ® 2009-2015 RunYusoft.com Inc. All Rights Reserved 
技术支持:betvictor xin1946润宇betvictor85科技有限公司  陕ICP备11000720号-3