1

次のパスワード要件を満たすようにユーザーに要求するように、regularexpressionvalidator コードを変更する必要があります。

を。少なくとも 2 つの大文字が含まれています:A, B, Cなど。

b. 少なくとも 2 つの小文字が含まれています:a, b, c,など。

c. 少なくとも 2 つの数字を含む:1,2,3,4,5,6,7,8,9,0

d. 少なくとも 2 つの特殊文字が含まれています。

! @ # $ % ^ & * ( ) _ + | ~ - = \ ` { } [ ] : " ; ' < > ? , . /

現在のコードでは、10 文字のパスワードの長さのみが必要です。

<asp:RegularExpressionValidator ID="valPassword" 
runat="server" ControlToValidate="txtPassword" 
ErrorMessage="Error: 10 character required password length"
ValidationExpression=".{10}.*" /> 
4

1 に答える 1

0

この正規表現を使用できます

^(?=^.{10}$)(?=^(.*?[A-Z]){2,}.*?$)(?=^(.*?[a-z]){2,}.*?$)(?=^(.*?\d){2,}.*?$)(?=^(.*?[!@#$%^&]){2,}.*?$).*?$
   --------  ---------------------  --------------------- ------------------- --------------------------
      |               |                       |                    |                      |->checks for 2 or more special characters
      |               |                       |                    |->checks for 2 or more digits 
      |               |                       |->checks for 2 or more small letters
      |               |->checks for 2 or more capital words
      |
      |->checks for 10 words..
于 2012-11-26T10:37:47.930 に答える