CreateUserWizard.PasswordRegularExpression Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a regular expression used to validate the provided password.
public:
virtual property System::String ^ PasswordRegularExpression { System::String ^ get(); void set(System::String ^ value); };
public virtual string PasswordRegularExpression { get; set; }
member this.PasswordRegularExpression : string with get, set
Public Overridable Property PasswordRegularExpression As String
Property Value
A string containing the regular expression used to validate the provided password. The default value is an empty string ("").
Examples
The following code example uses the PasswordRegularExpression 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.
<%@ page language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>CreateUserWizard.PasswordRegularExpression sample</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:createuserwizard id="Createuserwizard1" runat="server"
passwordregularexpression='@\"(?:.{7,})(?=(.*\d){1,})(?=(.*\W){1,})'
passwordregularexpressionerrormessage="Your password must be 7 characters long, and contain at least one number and one special character.">
</asp:createuserwizard>
</div>
</form>
</body>
</html>
<%@ page language="VB"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>CreateUserWizard.PasswordRegularExpression sample</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:createuserwizard id="Createuserwizard1" runat="server"
passwordregularexpression='@\"(?:.{7,})(?=(.*\d){1,})(?=(.*\W){1,})'
passwordregularexpressionerrormessage="Your password must be 7 characters long, and contain at least one number and one special character.">
</asp:createuserwizard>
</div>
</form>
</body>
</html>
Remarks
Use the PasswordRegularExpression 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.