Tyler Miranda
Tyler Miranda

Reputation: 433

validation problem

I'm having a validation issue that I can't figure out. I "know" I have it set up correctly but everytime it does not stop me on submit. Basically, I have a form and the only thing required in the form is a textbox called "tbEmail". Here is the code from my aspx page:

<tr>
            <td>
                <asp:TextBox ID="tbEmail" runat="server" Height="40px" Width="688px" 
                    Font-Size="20px" input-type="email" CausesValidation="True" AutoCompleteType="Email"></asp:TextBox>
            </td>
            <td>
                <asp:RegularExpressionValidator ID="regexEmail" runat="server" ControlToValidate="tbEmail" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="Email">
                </asp:RegularExpressionValidator>
                <asp:RequiredFieldValidator ID="rfvEmail" runat="server"  ValidationGroup="Email" ControlToValidate="tbEmail" ErrorMessage="*">
                </asp:RequiredFieldValidator>
        </td>
        </tr>

In my code behind, on the image button click event handler I have this:

protected void btnSubscribe_Click(object sender, ImageClickEventArgs e)
    {

        Page.Validate("Email");
        if (Page.IsValid)
        {
                //call the method 

                my method here...

                mvwForm.SetActiveView(vwSuccessEmail);


                ClearControls(Page);


        }
        else
            {
                lblValidation.Visible = true;
            }


    }

but everytime, if I leave the e-mail field blank it proceeds to load the vwSuccessEmail view. I have tried setting the tbEmail control to use ValidationGroup="Email" as well with the same result. Anyone catch what I'm missing here?

Upvotes: 1

Views: 118

Answers (1)

Arief
Arief

Reputation: 6085

I don't know if you already did it but you should set btnSubscribe to use ValidationGroup="Email" as well.

Upvotes: 3

Related Questions