Avatar of viola123
viola123
 asked on

How to disable/invisible the group validator in a web form?

hi All,
i have web form, it has two radio buttons and two panels, each panel will be made visible/invisible based on the radion button selection. there are a few RequiredValidators at the end of the form(not locate in panels). i grouped the validators based on panels.
my question is: how to disable/invisible the group validator based on the selection of the radio button OR based on the visiblity/invisibity of panels?

my code sample:
<asp:RequiredFieldValidator ID="AddressLine1Validator" runat="server" ErrorMessage="Address Line 1 required" ValidationGroup="valIndivDelGroup" ControlToValidate="txtBox_IndivDelAddressLine1" Display="None"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="PostcodeValidator" runat="server" ErrorMessage="Postcode required" ValidationGroup="valIndivDelGroup" ControlToValidate="txtBox_IndivDelPostcode" Display="None"></asp:RequiredFieldValidator>

thanks a lot
viola
ASP.NETWeb DevelopmentC#

Avatar of undefined
Last Comment
viola123

8/22/2022 - Mon
alfie77

Hi,

I asked exactly the same question a couple of days ago, you need to set the initial values of the controls to enabled false and have Javascript enable disable them:

There is a built-in function to do this:

var myVal = document.getElementById('<%=YOUR_VALIDATOR_ID_HERE.ClientID%>');
ValidatorEnable(myVal, false)

will disable the validator, true will enable it.
alfie77

viola123

ASKER
hi,
thanks. but i want to disable the group validators(in my code: i grouped the validators using ValidationGroup="valIndivDelGroup"). i am wondering how to make the group validator invisible/disable. in you code, the javascript is using to disable a specified validator not a group.

thanks
viola
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
viola123

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.