Zoom Asp.net

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.

Validation Group Example

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 :)

4 Comments more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Failed creating file mapping PHP Fatal error: Failed creating file mapping in Unknown on line 0 PHP Fatal error: XCache: Cannot create shm in Unknown on line 0