Edit

Share via


CreateUserWizard.EmailRegularExpression Property

Definition

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

Property Value

A string containing the regular expression used to validate an email address. The default value is an empty string ("").

Examples

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>

Remarks

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.

Applies to

See also