• 正则判断密码难度


      

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            span{
                display: none;
            }
        </style>
    </head>
    <body>
    <input type="password" class="mm">
    <span class="r">弱</span>
    <span class="z">中</span>
    <span class="q">强</span>
    
    <script>
        var mm=document.querySelector(".mm");
        var sp=document.querySelectorAll("span")
        mm.onblur=function () {
            var flag=0;
            if(/[0-9]/.test(this.value)){
                flag++;
                console.log("数字")
            }
            if(/[a-zA-Z_]/.test(this.value)){
                flag++;
                console.log("字母")
            }
            if(/W/.test(this.value)){
                flag++;
                console.log("特殊")
            }
            function hide(){
                for(var i=0;i<sp.length;i++){
                    sp[i].style.display="none";
                }
            }
            switch (flag) {
                case 1:
                    hide();
                    document.querySelector(".r").style.display="block"
                    break;
                case 2:
                    hide();
                    document.querySelector(".z").style.display="block"
                    break;
                case 3:
                    hide();
                    document.querySelector(".q").style.display="block"
                    break;
            }
    
        }
        function hide() {
            for (var i=0;i<sp.length;i++) {
                sp[i].style.display="none";
            }
        }
    </script>
    </body>
    </html>
    

      

  • 相关阅读:
    GPU编程和流式多处理器(七)
    GPU编程和流式多处理器(六)
    vue——使用vant轮播组件swipe + flex时,文字抖动问题
    golang 修改字符串
    Go 彻底弄懂return和defer的微妙关系
    Redis 的持久化机制
    Redis 缓存击穿
    Redis 缓存穿透
    Redis 雪崩
    正则验证
  • 原文地址:https://www.cnblogs.com/daifuchao/p/11781250.html
Copyright © 2020-2023  润新知