The approximate implementation process is as follows:
1, add properties to the validation control: validationgroup= "VgA" (group name casually write)
2, modify the properties of the Save button: Causesvalidation=false
3, add onclientclick= validatebygruop to the Save button ()
The code is as follows:
function validatebygruop ()
{
&N bsp; var Retval=false;
var val = $ (' #<%= drop-down list control Id.clientid%> option:selected '). Val ();
if (val = 1)
{
//Validate only mining required
retval= page_clientvalidate ("mustvalidate");
}
else
{
//Validate all items
& nbsp; retval= page_clientvalidate ();
}
return retval;
}
4, if you want to use the ValidationSummary control to display the summarized validation information, set its validationgroup= "group name" to
Supplementary notes;
1,page_clientvalidate method
Page_clientvalidate (ValidationGroup)
The parameter is the value of the ValidationGroup property. Validator control that triggers all pages of a page without specifying a parameter.
The return value is a Boolean value (true: validation passed, false: Validation failed).
2, on a page containing RequiredFieldValidator controls, RequiredFieldValidator controls are sent to the client to generate some web effects functions, causesvalidation= "True" button is only a bit more JavaScript code than the button causesvalidation= "False"