enable disable validation group Client Side using Javascript in asp.net
by chintan prajapati on Mar.10, 2008, under ASP.net, Javascript, ValidationGroup
Recently i faced problem in validating Address Control which basically depends on selection of radio button.below is the figure of problem.

Here All controls below Gift to this Address Radiobutton should not fire validation if it is not checked. Asp.net Simply does all validation and shows all errormessage even if Gift to this Address is not selected, so all you have to do is create validation group for left address block called “ADDRESS” by assigning ValidationGroup Property value of “ADDRESS”.
Put this code for Button named “Done”
OnClientClick=”EnableDisableValidation();”
javascript function EnableDisableValidation() looks like below.
function EnableDisableValidation()
{
if($L(’rdbMyAddress’).checked)
{
return Page_ClientValidate(’Address’);
}
else if($L(’rdbAddressGift’).checked)
{
if( Page_ClientValidate())
{ return true;}
else
{ return false;}
}
}
Where $L is replacement of document.getElementById(”);
Page_ClientValidate(’Address’) function Validates All Control having property ValidationGroup =”Address”.
Where as Page_ClientValidate() Blindly validates all validation Controls within page.
I hope now you are clear with idea of customized validation control.
i can share more code with you if still not clear.
feel free to put your comments ![]()
happy codding ![]()






July 3rd, 2008 on 12:42 pm
I tried your method and it seems that the javascript function was never called during the process, instead it went straight to the validation first, can you help? Thanks
July 24th, 2008 on 6:56 am
Thanks, that’s just what I was looking for!
Regards, Bart
January 19th, 2009 on 11:27 pm
but i can’t understand
from where 2 start& how to go further
implementation & reach at the end for fetching addresses/contacts of yahoo/gmail through c# code
February 2nd, 2009 on 1:29 pm
Can you post more code or share your actual ASPX & Code behind files? I couldn’t get this to work.
Thanks!