Validation not working

Joined
Mar 23, 2010
Messages
1
Reaction score
0
Hello there...

can somebody guide me on this…

I have a panel (say, panel1) inside another panel (say, outer-panel)….The panel1 is visible only when a checkbox is checked in the outer-panel.

I have many text boxes in the panel1. I have to put a validation on all the boxes.
I have to enable the validations on certain conditions,say, if textbox 1 is filled only then the required-field validator for textbox 2 should be enabled and vice-versa.
I did write code in the page_load for this.
Code:
if (txt1.Text != "")
            {
                required_txt2.Enabled = true;

            }
            else
            {
                required_txt2.Enabled = false;
            }
            if (txt2.Text != "")
            {
                required_txt1.Enabled = true;
            }
            else
            {
                required_txt1.Enabled = false;
            }

This code does enable the validator but does not show any error if one the textboxes is not filled and the page gets submitted normally.
the asp code for the validators is,
Code:
<asp:RequiredFieldValidator ID="required_txt1" runat="server" ErrorMessage="Please enter the text."
                    ControlToValidate="txt1" EnableClientScript="false" Enabled="false" Display="Dynamic"
                    SetFocusOnError="true" ValidationGroup="Submit">*</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="required_txt2" runat="server" Enabled="false" EnableClientScript="false"
                    ErrorMessage="Please enter the text 2." ControlToValidate="txt2" SetFocusOnError="true"
                    Display="Dynamic" ValidationGroup="Submit">*</asp:RequiredFieldValidator>

Can somebody please tell me what could be the reason…thanks in advance….
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top