Secret of ASP.NET Validation control

In your projects you must have used ASP.NET validation controls like Required Field Validator, Range Validator, Custom validator, etc.

Suppose in a page you have used Required Field Validator for a textbox, so while Form submission it will validate the textbox control for its value.

But if you want to disable validation for a particular validator from JavaScript then what  do you do. You can use the following code snippet to handle it –

ValidatorEnable('', false);

Here “reqVal_txtName” is the ID of the Required Field validator and we are making the validation to false for that control.

Consider another scenario where you want to execute some javascript code after successful validation of all the controls in the page, then what to do ?
This is also simple, just validate all Validation controls for the page before executing the Javascript code. Which can be done as follows –

// Check whether all the validations in the page are done or not.
   Page_ClientValidate();
   var pageValidated = Page_IsValid;

   // If all client-side validations are done then execute javascript code.
   if (pageValidated)
   {
       // Place your Javascript code here.
   }
150 150 Burnignorance | Where Minds Meet And Sparks Fly!