Archive for March, 2008
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 ![]()