Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Validation Summary: How to disable validator with JavaScript?

I want to disable a ASP.NET RequiredFieldValidator with JavaScript. Actually I'm using the following code:

function doSomething() 
{ 
  var myVal = document.getElementById('myValidatorClientID'); 
  ValidatorEnable(myVal, false);  
} 

This disables the validator. But my problem is, that I'm using a ValidationSummary. And this summary shows the validation message, even if I disable the validator.

Can someone tell me, how to disable the validator in the ValidationSummary too?

like image 217
Torben Avatar asked Jan 27 '10 16:01

Torben


People also ask

What is validation summary control in asp net?

The ValidationSummary control enables you to display a list of all the validation errors in a page in one location. This control is particularly useful when working with large forms. If a user enters the wrong value for a form field located toward the end of the page, then the user might never see the error message.

What is control validator?

Validation controls are used to, Implement presentation logic. To validate user input data. Data format, data type and data range is used for validation.


1 Answers

The solution is to add a call to ValidationSummaryOnSubmit() after you disable the validator.

function doSomething()  
{  
    var myVal = document.getElementById('myValidatorClientID');  
    ValidatorEnable(myVal, false);   
    ValidationSummaryOnSubmit();
}

You can find a file called WebUIValidation.js on your development computer, which contains the client side JavaScript functions used by the ASP.NET validation process. The functions are well named and it's generally fairly easy to figure out what each of them do.

like image 159
Jason Berkan Avatar answered Sep 28 '22 04:09

Jason Berkan