Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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 email address.
public:
virtual property System::String ^ EmailRegularExpression { System::String ^ get(); void set(System::String ^ value); };
public virtual string EmailRegularExpression { get; set; }
member this.EmailRegularExpression : string with get, set
Public Overridable Property EmailRegularExpression As String
A string containing the regular expression used to validate an email address. The default value is an empty string ("").
The following code example assigns a regular expression to the EmailRegularExpression property to make sure that the user entered their email address in a valid format, such as username@contoso.com.
<%@ 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.EmailRegularExpression sample</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:createuserwizard id="Createuserwizard1" runat="server"
emailregularexpression='@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"'
emailregularexpressionerrormessage="Email address must be in a valid format">
</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 runat="server">
<title>CreateUserWizard.EmailRegularExpression sample</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:createuserwizard id="Createuserwizard1" runat="server"
emailregularexpression='@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"'
emailregularexpressionerrormessage="Email address must be in a valid format">
</asp:createuserwizard>
</div>
</form>
</body>
</html>
Use the EmailRegularExpression property to specify a regular expression that validates the email address entered by the user to confirm that it matches a specific pattern. A common use is to make sure that the user has entered a complete email address, such as user@contoso.com. The regular expression is used in addition to any restrictions placed on the email address by the membership provider specified in the MembershipProvider property. If the membership provider rejects the email address for any reason, the text contained in the InvalidEmailErrorMessage property is displayed.
The address is only compared to the regular expression if the RequireEmail property is set to true
.
If the email address does not pass the regular expression, the text contained in the EmailRegularExpressionErrorMessage property is displayed to the user.
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in