Validation Issue
-
Hi guys, I have 3 submit buttons on a single page. Each submit button is linked to its controls via a "ValidationGroup". One of the groups even has a Custom Validator. The problem I am having is that the validation is not even firing. I have no idea why. I hope the answer is not silly :( Here is the HTML for ONE of the groups:
<div id="dvRegistrationValidation" runat="server">
<asp:RequiredFieldValidator ID="rfvRegistrationCode" ControlToValidate="txtRegistrationCode"
Display="None" ValidationGroup="RegistrationProcess" ErrorMessage="Registration Code"
runat="server"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="cstTarget" runat="server" ErrorMessage="Either Head Office or Farm Site/Unit"
ValidationGroup="RegistrationProcess" OnServerValidate="cstTarget_ServerValidate"
Display="None"></asp:CustomValidator>
<asp:ValidationSummary ID="vsRegistration" runat="server" DisplayMode="BulletList"
ShowSummary="true" HeaderText="The following fields are mandatory:" ValidationGroup="RegistrationProcess" />
</div>And here is the OnServerValidate Sub Routine:
Sub cstTarget\_ServerValidate(ByVal source As Object, ByVal e As ServerValidateEventArgs) Handles cstTarget.ServerValidate If Me.chkTarget1.Checked = True And Me.chkTarget2.Checked = True Then e.IsValid = False ElseIf Me.chkTarget1.Checked = False And Me.chkTarget2.Checked = False Then e.IsValid = False ElseIf Me.chkTarget1.Checked = True And Me.chkTarget2.Checked = False Then e.IsValid = True ElseIf Me.chkTarget1.Checked = False And Me.chkTarget2.Checked = True Then e.IsValid = True End If End Sub
I appreciate any help given. Thanks!
-
Hi guys, I have 3 submit buttons on a single page. Each submit button is linked to its controls via a "ValidationGroup". One of the groups even has a Custom Validator. The problem I am having is that the validation is not even firing. I have no idea why. I hope the answer is not silly :( Here is the HTML for ONE of the groups:
<div id="dvRegistrationValidation" runat="server">
<asp:RequiredFieldValidator ID="rfvRegistrationCode" ControlToValidate="txtRegistrationCode"
Display="None" ValidationGroup="RegistrationProcess" ErrorMessage="Registration Code"
runat="server"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="cstTarget" runat="server" ErrorMessage="Either Head Office or Farm Site/Unit"
ValidationGroup="RegistrationProcess" OnServerValidate="cstTarget_ServerValidate"
Display="None"></asp:CustomValidator>
<asp:ValidationSummary ID="vsRegistration" runat="server" DisplayMode="BulletList"
ShowSummary="true" HeaderText="The following fields are mandatory:" ValidationGroup="RegistrationProcess" />
</div>And here is the OnServerValidate Sub Routine:
Sub cstTarget\_ServerValidate(ByVal source As Object, ByVal e As ServerValidateEventArgs) Handles cstTarget.ServerValidate If Me.chkTarget1.Checked = True And Me.chkTarget2.Checked = True Then e.IsValid = False ElseIf Me.chkTarget1.Checked = False And Me.chkTarget2.Checked = False Then e.IsValid = False ElseIf Me.chkTarget1.Checked = True And Me.chkTarget2.Checked = False Then e.IsValid = True ElseIf Me.chkTarget1.Checked = False And Me.chkTarget2.Checked = True Then e.IsValid = True End If End Sub
I appreciate any help given. Thanks!
-
Hi guys, I have 3 submit buttons on a single page. Each submit button is linked to its controls via a "ValidationGroup". One of the groups even has a Custom Validator. The problem I am having is that the validation is not even firing. I have no idea why. I hope the answer is not silly :( Here is the HTML for ONE of the groups:
<div id="dvRegistrationValidation" runat="server">
<asp:RequiredFieldValidator ID="rfvRegistrationCode" ControlToValidate="txtRegistrationCode"
Display="None" ValidationGroup="RegistrationProcess" ErrorMessage="Registration Code"
runat="server"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="cstTarget" runat="server" ErrorMessage="Either Head Office or Farm Site/Unit"
ValidationGroup="RegistrationProcess" OnServerValidate="cstTarget_ServerValidate"
Display="None"></asp:CustomValidator>
<asp:ValidationSummary ID="vsRegistration" runat="server" DisplayMode="BulletList"
ShowSummary="true" HeaderText="The following fields are mandatory:" ValidationGroup="RegistrationProcess" />
</div>And here is the OnServerValidate Sub Routine:
Sub cstTarget\_ServerValidate(ByVal source As Object, ByVal e As ServerValidateEventArgs) Handles cstTarget.ServerValidate If Me.chkTarget1.Checked = True And Me.chkTarget2.Checked = True Then e.IsValid = False ElseIf Me.chkTarget1.Checked = False And Me.chkTarget2.Checked = False Then e.IsValid = False ElseIf Me.chkTarget1.Checked = True And Me.chkTarget2.Checked = False Then e.IsValid = True ElseIf Me.chkTarget1.Checked = False And Me.chkTarget2.Checked = True Then e.IsValid = True End If End Sub
I appreciate any help given. Thanks!
... and you could reduce the validate method to a simple
e.IsValid = Me.chkTarget1.Checked <> Me.chkTarget2.Checked
:)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.
-
... and you could reduce the validate method to a simple
e.IsValid = Me.chkTarget1.Checked <> Me.chkTarget2.Checked
:)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.
-
you're welcome. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.