---
title: "Adding Regex Validators with CreateUserWizard they are not Working"  
description: "Adding Regex Validators with CreateUserWizard they are not Working"  
author: "Takeshi Okada"  
published: 2013-10-05  
updated: 2013-10-05  
canonical: https://www.mindstick.com/forum/1592/adding-regex-validators-with-createuserwizard-they-are-not-working  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 12 minutes  

---

# Adding Regex Validators with CreateUserWizard they are not Working

I am adding some [regex](https://www.mindstick.com/forum/160352/how-to-use-regex-in-javascript-for-pattern-matching) with the [register](https://www.mindstick.com/blog/220/registering-client-script-in-asp-dot-net) [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) steps, they are working because the '*' is being displayed but the [Wizard](https://answers.mindstick.com/qa/34027/which-sporstman-is-known-as-the-wizard-of-hockey) will still let me create an [account](https://www.mindstick.com/articles/33699/how-tech-is-disrupting-the-accounting-world) with [errors](https://answers.mindstick.com/qa/116170/fresh-fir-against-gandhis-in-national-herald-case-cover-up-for-ed-s-own-errors) of regex.

1. I tried to redo the wizard

2. Changing some [features](https://www.mindstick.com/articles/12993/5-advanced-features-for-your-odoo-ecommerce-theme) but nothing

**[Page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) [Source](https://www.mindstick.com/interview/840/what-happens-if-the-both-source-and-destination-are-named-same)**

```
<asp:CreateUserWizard ID="RegisterUser" runat="server" CssClass="gridviewUsers"
        oncreateduser="RegisterUser_CreatedUser1">
        <WizardSteps>
            <asp:CreateUserWizardStep runat="server">
                <ContentTemplate>
                    <table>
                        <tr>
                            <td align="center" colspan="2">
                                Sign Up for Your New Account</td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="UserName" runat="server"
                                    ToolTip="The Username that you will need to login later  eg &quot;john123&quot;"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rv1_1" runat="server"
                                    ControlToValidate="UserName" ErrorMessage="User Name is required."
                                    ForeColor="Red" ToolTip="User Name is required."
                                    ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="rv1_2" runat="server"
                                    ControlToValidate="UserName" ErrorMessage="Not a valid Username"
                                    ForeColor="Red" ValidationExpression="^[a-z0-9_-]{3,15}$"
                                    ValidationGroup="CreateUserWizard1">*</asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="Password" runat="server" TextMode="Password"
                                    ToolTip="The password for the selected username eg&quot;123456&quot;"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rv2_1" runat="server"
                                    ControlToValidate="Password" ErrorMessage="Password is required."
                                    ForeColor="Red" ToolTip="Password is required."
                                    ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="rv2_2" runat="server"
                                    ControlToValidate="Password"
                                    ErrorMessage="Invalid Password Please enter a valid password rg&quot;pass12&quot;"
                                    ForeColor="Red" ValidationExpression="^[A-Za-z0-9]+$"
                                    ValidationGroup="CreateUserWizard1">*</asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Label ID="ConfirmPasswordLabel" runat="server"
                                    AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"
                                    ToolTip="Must enter the same password as above  to confirm password"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rv3_1" runat="server"
                                    ControlToValidate="ConfirmPassword"
                                    ErrorMessage="Confirm Password is required." ForeColor="Red"
                                    ToolTip="Confirm Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="rv3_2" runat="server"
                                    ControlToValidate="ConfirmPassword"
                                    ErrorMessage="Invalid Password Please enter a valid password rg&quot;pass12&quot;"
                                    ForeColor="Red" ValidationExpression="^[A-Za-z0-9]+$"
                                    ValidationGroup="CreateUserWizard1">*</asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="Email" runat="server"
                                    ToolTip="The email on which we will use to contact you!"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rv4_1" runat="server" ControlToValidate="Email"
                                    ErrorMessage="E-mail is required." ForeColor="Red"
                                    ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="rv4_2" runat="server"
                                    ControlToValidate="Email" ErrorMessage="Email invalid format" ForeColor="Red"
                                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                    ValidationGroup="CreateUserWizard1">*</asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td align="right">
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td align="center" colspan="2">
                                <asp:CompareValidator ID="PasswordCompare" runat="server"
                                    ControlToCompare="Password" ControlToValidate="ConfirmPassword"
                                    Display="Dynamic"
                                    ErrorMessage="The Password and Confirmation Password must match."
                                    ForeColor="Red" ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="center" colspan="2" style="color:Red;">
                                <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </asp:CreateUserWizardStep>
            <asp:CompleteWizardStep runat="server" />
        </WizardSteps>
    </asp:CreateUserWizard>
```

**[Aspx File](https://www.mindstick.com/forum/108/is-it-possible-to-see-the-code-that-asp-dot-net-generates-from-an-aspx-file)**\

##

```
 protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            if (CheckUsername() != true)
            {
                Roles.AddUserToRole(RegisterUser.UserName, "Pre-Member");
                FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);
                string continueUrl = RegisterUser.ContinueDestinationPageUrl;
                if (String.IsNullOrEmpty(continueUrl))
                {
                    continueUrl = "~/Account/InsertingUserDetails.aspx";
                }
                Response.Redirect(continueUrl);
            }
            else
            {
                RegisterUser.UserNameRequiredErrorMessage = "User already taken";
            }
        }
```

## Replies

### Reply by E E Cummings

Assuming your Create Use wizard looks like this

```
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" OnCreatedUser="CreateUserWizard1_CreatedUser"
    DisableCreatedUser="true" EmailRegularExpression="^((?:(?:(?:\w[\.\-\+]?)*)\w)+)\@((?:(?:(?:\w[\.\-\+]?){0,62})\w)+)\.(\w{2,4})$"
    Font-Size="Small">
    <CreateUserButtonStyle CssClass="button" />
    <ErrorMessageStyle Font-Size="Small" />
    <TextBoxStyle CssClass="textbox txtsingleline" />
    <ValidatorTextStyle Font-Size="Small" />
    <WizardSteps>
        <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
        </asp:CreateUserWizardStep>
        <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
        </asp:CompleteWizardStep>
    </WizardSteps>
</asp:CreateUserWizard>
```

\

You can access the validators as follows:

```
(RequiredFieldValidator)((CreateUserWizardStep)CreateUserWizard1.FindControl("CreateUserWizardStep1")).ContentTemplateContainer.FindControl("UserNameRequired")
(RequiredFieldValidator)((CreateUserWizardStep)CreateUserWizard1.FindControl("CreateUserWizardStep1")).ContentTemplateContainer.FindControl("PasswordRequired")
(RequiredFieldValidator)((CreateUserWizardStep)CreateUserWizard1.FindControl("CreateUserWizardStep1")).ContentTemplateContainer.FindControl("ConfirmPasswordRequired")
(RequiredFieldValidator)((CreateUserWizardStep)CreateUserWizard1.FindControl("CreateUserWizardStep1")).ContentTemplateContainer.FindControl("EmailRequired")
(CompareValidator)((CreateUserWizardStep)CreateUserWizard1.FindControl("CreateUserWizardStep1")).ContentTemplateContainer.FindControl("PasswordCompare")
(RegularExpressionValidator)((CreateUserWizardStep)CreateUserWizard1.FindControl("CreateUserWizardStep1")).ContentTemplateContainer.FindControl("EmailRegExp")
```


---

Original Source: https://www.mindstick.com/forum/1592/adding-regex-validators-with-createuserwizard-they-are-not-working

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
