function validPsw() {  
    var password = $(".password").val();  
    var num = 0;  
    var number = 0 ;  
    var letter = 0 ;  
    var bigLetter = 0 ;  
    var chars = 0 ;  
      
    if (password.search(/[0-9]/) != -1) {  
        num += 1;  
        number =1;  
    }  
    if (password.search(/[A-Z]/) != -1) {  
        num += 1;  
        bigLetter = 1 ;  
    }  
    if (password.search(/[a-z]/) != -1) {  
        num += 1;  
        letter = 1 ;  
    }  
    if (password.search(/[^A-Za-z0-9]/) != -1) {  
        num += 1;  
        chars = 1 ;  
    }  
    if (num >= 2 && (password.length >= 6 && password.length <= 16)) {  
        $(".pswSpan").html("");  
        $(".password").css("border","#B0B0B0 solid 1px");  
    }else if(password.length < 6 || password.length > 16){  
        $(".pswSpan").html("密码由6-16个字符组成!");  
        $(".password").css("border","#B35D5D solid 1px");  
    }else if(num == 1){  
        if(number==1){  
            $(".pswSpan").html("不能全为数字!");  
        }  
        if(letter==1){  
            $(".pswSpan").html("不能全为字母!");  
        }  
        if(bigLetter==1){  
            $(".pswSpan").html("不能全为字母!");  
        }  
        if(chars==1){  
            $(".pswSpan").html("不能全为字符!");  
        }  
        $(".password").css("border","#B35D5D solid 1px");  
    }  
}  
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2021-09-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案