zoukankan      html  css  js  c++  java
  • JS 密码弱中强显示

    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <meta charset="utf-8" />
        <script>
            onload = function () {
                var tds = document.getElementById('tb').getElementsByTagName('td');


                document.getElementById('txt').onkeyup = function () {
                    for (var i = 0; i < tds.length; i++) {//防止输入正确密码后倒退删除时候出问题
                        tds[i].style.backgroundColor = 'gray';
                    }
                    if (this.value.length>0) {
                        var result = checkPwd(this.value);
                        if (result<=1) {//弱
                            tds[0].style.backgroundColor='red';
                        }else if (result==2) {//中
                            tds[0].style.backgroundColor='green';
                            tds[1].style.backgroundColor='green';
        
                        }else if (result==3) {//强
                            tds[0].style.backgroundColor='blue';
                            tds[1].style.backgroundColor='blue';
                            tds[2].style.backgroundColor='blue';
                        }
                    }
                }
            }


            function checkPwd(msg){ //判断含有数字字母特殊符号
                var lvl = 0;
                if (msg.match(/[0-9]/)){
                    lvl++;
                }
                if (msg.match(/[a-zA-Z]/)) {
                    lvl++;
                }
                if (msg.match(/[^0-9a-zA-Z]/)) {
                    lvl++;
                }
                if (msg.length<6) {
                    lvl--;
                }
                return lvl;
            }

        </script>
    </head>
    <body>
        <input type="text" name="name" id="txt" />
        <table id="tb" border="1" style="300px;height:35px;text-align:center;background-color:gray">
            <tr>
                <td>
                    弱
                </td>
                <td>
                    中
                </td>
                <td>
                    强
                </td>


            </tr>
        </table>
    </body>
    </html>
  • 相关阅读:
    RestTemplateConfig写法,用于配置Template引擎模板
    RedisUtil写法,好用
    ftpUtil写法,记录一下
    生成唯一id写法,雪花算法
    base64编码转图片,图片转base64编码
    MultipartFile上传图片的写法,记录一下。
    httpClientUtil的put请求
    httpClientUtil的post请求
    python time和datetime
    ubuntu16.04TLS软件源update
  • 原文地址:https://www.cnblogs.com/dxmfans/p/9434852.html
Copyright © 2011-2022 走看看