• 做了一个密码强度输入测试


    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>密码强度输入测试</title>
    <style type="text/css">
    .cont { margin-left:300px; margin-top:50px; border:solid 1px #ccc; width:520px; padding:20px;}
    .passwd {
        
        margin-bottom: 10px;
    }
    table td p { display:block; border-top:solid 4px #ccc; text-align:center; margin-right:10px; line-height:22px;}
    .red { border-top-color:#e00;}
    .green { border-top-color:#3C3;}
    .blue { border-top-color:#0CF;}
    .passwd span {
        font-size: 13px;
        color: #888;
        
    }
    .passwd span em { color:#f00; font-style:normal;}
    </style>
    </head>
    
    <body>
    <div class="cont">
      <div class="passwd">密码:<input name="" type="password" id="passwd" /> <span><em>*</em>6-16位,由字母(区分大小写)、数字、符号组成</span>
      </div>
      <table width="200" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td><p></p></td>
          <td><p></p></td>
          <td><p></p></td>
        </tr>
      </table>
    </div>
    
    <script type="text/javascript">
    var reg = /[^A-z0-9]|[^[]]/ ;
    var s = reg.test("ds33");
    console.log(s);
    var pass = document.getElementById("passwd");
    var zt  = document.querySelectorAll("table tr p");
    pass.addEventListener("focus",jiance);
    pass.addEventListener("blur",shifang);
    
    function shifang (e){
        ceshi(e);
        pass.removeEventListener("keyup",ceshi);
        }
    function jiance (){
        
        pass.addEventListener("keyup",ceshi);
        
        
    }
    
    function ceshi (e){
            var txt = e.target.value ;
            if(txt.length>16){
                e.target.value = txt.substr(0,16);    
            }
            if(txt){
                var qiangdu = AuthPasswd(txt);
                switch (qiangdu){
                    case 0:
                    zt[0].className = "red";
                    zt[1].className = ""; 
                    zt[2].className = ""; 
                    break;
                    case 1:
                    zt[0].className = "red"; 
                    zt[1].className = "green";
                    zt[2].className = "";  
                    break;
                    case 2:
                    zt[0].className = "red"; 
                    zt[1].className = "green"; 
                    zt[2].className = "blue";
                    break;
                    }        
            }
        else {
                    zt[0].className = ""; 
                    zt[1].className = ""; 
                    zt[2].className = "";
            }
    }
    
    
    function AuthPasswd(string) {
        if(string.length >=6) {
            if(/[a-zA-Z]/.test(string) && /[0-9]/.test(string) && /[^A-z0-9]|[^[]]/.test(string)) {
                return 2 ;
            }else if(/[a-zA-Z]/.test(string) || /[0-9]/.test(string) || /[^A-z0-9]|[^[]]/.test(string)) {
                if(/[a-zA-Z]+/.test(string) && /[0-9]/.test(string)) {
                    return 1 ;
                }else if(/[a-zA-Z]/.test(string) && /[^A-z0-9]|[^[]]/.test(string)) {
                    return 1 ;
                }else if(/[0-9]/.test(string) && /[^A-z0-9]|[^[]]/.test(string)) {
                    return 1 ;
                }else{
                    return 0 ;
                }
            }
        }else{
            return 0 ;
        }
    }
    </script>
    </body>
    </html>

    直接写一个代码吧,没什么技术含量。

  • 相关阅读:
    org.springframework.beans.BeanUtils属性赋值 Date类型处理转换为LocalDateTime, Date不能直接赋值给LocalDateTime
    python rabbitmq官方文档demo
    rabbitmq安装
    python 文件查找及截取字符串 (替换,分割) demo
    python pika rabbitmq demo
    python xlrd excel读取操作
    python pymysql 数据库查询操作
    GO语言学入门学习,学习资料推荐
    linux安装uwsgi错误:gcc returned 1 exit status error: lto-wrapper failed collect2:
    anconda的使用以及在conda环境中使用pip和conda使用安装依赖的区别和注意事项
  • 原文地址:https://www.cnblogs.com/xiaotian747/p/3759832.html
Copyright © 2020-2023  润新知