Regex for alphanumeric password, with at least 1 number and character

前端 未结 6 1953
礼貌的吻别
礼貌的吻别 2020-12-18 13:02

Need help with a regex for alphanumeric password, with at least 1 number and character, and the length must be between 8-20 characters.

I have this but doesn\'t seem

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 13:38

    This code is for javascript

    // *********** ALPHA-Numeric check ***************************
    function checkAlphaNumeric(val)
    {
        var mystring=new String(val)
    
        if(mystring.search(/[0-9]+/)==-1) // Check at-leat one number
        {
            return false;
        }
        if(mystring.search(/[A-Z]+/)==-1 && mystring.search(/[a-z]+/)==-1) // Check at-leat one character
        {
            return false;
        }
    }
    

提交回复
热议问题