2014-09-02 69 views
0

谁能告诉我什么是密码字段中validation。我是检查密码strength,无论我输入什么都总是说:错在这里“密码必须至少含有一个一个数字和一个字符检查密码强度

jQuery.validator.addMethod("pwcheck", function(value) { 
    return /^[[email protected]#$%^&*()_]$/.test(value) // consists of only these 
     && /[a-z]/.test(value) // has a lowercase letter 
     && /\d/.test(value) // has a digit 
}, "password must contain atleast one number and one character"); 

我想检查我的密码字段允许至少一个数字,一个字符和任意数量的specialcharacters /数字/字符

回答

1

您的第一个正则表达式是说它只能有一个角色......所以将其更改为

/^[[email protected]#$%^&*()_]+$/.test(value)// add + to indicate one or more instances of the set 

演示:Fiddle

1

试试这个,

jQuery.validator.addMethod("pwcheck", function(value) { 
    return /^[[email protected]#$%^&*()_]+$/.test(value)&& /[a-z]/.test(value) 
    && /\d/.test(value) ; 
}, "password must contain atleast one number and one character");