Thursday, 24 March 2011

Asp.Net Validation Summary: How to show ValidationSummary using JavaScript

Hi,
Few days back i got a situation that i need to run Validation of a particular ValidatorControl (RequiredFieldValidator) using ValidatorEnable function and was need to show ValidationSummary to show its result.
Achieved the same using ValidationSummaryOnSubmit(); function exposed at client side.

<script type="text/javascript" language="javascript">

function PerformValidation() {
              ValidatorValidate(document.getElementById('rfvName'));
              ValidationSummaryOnSubmit();
 }


</script>
 
Note:  ValidationSummaryOnSubmit takes an argument as validationGroup. If you want to show ValidationSummary for a particular validation group, then call function passing name of validation group.
If function is called without any arguments, then it will show all ValidationSummary (if error) in page.





No comments:

Post a Comment