密码必须由大小写字母、数字、特殊字符混合组成,而且不能少于六位。谢谢啊

解决方案 »

  1.   

    主要 是大小写判断啊
     if(/^[a-zA-Z_]{1}(\w)*$/g.test(password)){
                 alert("密码必须由大小写字母,数字和特殊字符混合组成");
            return  false;
    不能判断大小写,
      

  2.   

    var getStrength = function(passwd) {
    intScore = 0;
    if (passwd.match(/[a-z]/)) // [verified] at least one lower case letter
    {
    intScore = (intScore+1)
    } if (passwd.match(/[A-Z]/)) // [verified] at least one upper case letter
    {
    intScore = (intScore+5)
    } // NUMBERS
    if (passwd.match(/\d+/)) // [verified] at least one number
    {
    intScore = (intScore+5)
    } if (passwd.match(/(\d.*\d.*\d)/)) // [verified] at least three numbers
    {
    intScore = (intScore+5)
    } // SPECIAL CHAR
    if (passwd.match(/[!,@#$%^&*?_~]/)) // [verified] at least one special character
    {
    intScore = (intScore+5)
    } if (passwd.match(/([!,@#$%^&*?_~].*[!,@#$%^&*?_~])/)) // [verified] at least two special characters
    {
    intScore = (intScore+5)
    } // COMBOS
    if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/)) // [verified] both upper and lower case
    {
    intScore = (intScore+2)
    } if (passwd.match(/\d/) && passwd.match(/\D/)) // [verified] both letters and numbers
    {
    intScore = (intScore+2)
    } // [Verified] Upper Letters, Lower Letters, numbers and special characters
    if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/) && passwd.match(/\d/) && passwd.match(/[!,@#$%^&*?_~]/))
    {
    intScore = (intScore+2)
    }
    return intScore;
    }看看这例子.
      

  3.   

    var getStrength = function(passwd) {
    intScore = 0;
    if (passwd.match(/[a-z]/)) // [verified] at least one lower case letter
    {
    intScore = (intScore+1)
    } if (passwd.match(/[A-Z]/)) // [verified] at least one upper case letter
    {
    intScore = (intScore+5)
    } // NUMBERS
    if (passwd.match(/\d+/)) // [verified] at least one number
    {
    intScore = (intScore+5)
    } if (passwd.match(/(\d.*\d.*\d)/)) // [verified] at least three numbers
    {
    intScore = (intScore+5)
    } // SPECIAL CHAR
    if (passwd.match(/[!,@#$%^&*?_~]/)) // [verified] at least one special character
    {
    intScore = (intScore+5)
    } if (passwd.match(/([!,@#$%^&*?_~].*[!,@#$%^&*?_~])/)) // [verified] at least two special characters
    {
    intScore = (intScore+5)
    } // COMBOS
    if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/)) // [verified] both upper and lower case
    {
    intScore = (intScore+2)
    } if (passwd.match(/\d/) && passwd.match(/\D/)) // [verified] both letters and numbers
    {
    intScore = (intScore+2)
    } // [Verified] Upper Letters, Lower Letters, numbers and special characters
    if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/) && passwd.match(/\d/) && passwd.match(/[!,@#$%^&*?_~]/))
    {
    intScore = (intScore+2)
    }
    return intScore;
    }
    选错高亮了..