Gets or sets a regular expression used to validate the provided password.
Assembly: System.Web (in System.Web.dll)
abstract PasswordRegularExpression : string with get, set override PasswordRegularExpression : string with get, set
Property ValueType: System.String
A string containing the regular expression used to validate the provided password. The default value is an empty string ("").
Use the property to define the requirements for passwords used to validate users on your Web site. A common use is to make sure that a user has included symbols other than letters in a password to make it harder for attackers to guess a password. The regular expression is used in addition to any restrictions placed on the password by the membership provider specified in the MembershipProvider property. If the membership provider rejects the password for any reason, the text contained in the InvalidPasswordErrorMessage property is displayed.
If the password entered does not pass the regular expression, the error message contained in the PasswordRegularExpressionErrorMessage property is displayed to the user.
The following code example uses the property to define a regular expression that checks passwords to ensure that they:
Are longer than seven characters.
Contain at least one digit.
Contain at least one special (non-alphanumeric) character.
If the password entered by the user does not meet these criteria, the text contained in the PasswordRegularExpressionErrorMessage property is displayed to the user.