A jQuery Plugin that will toggle the active state of ASP.NET Validators.
ASP.NET provides a number of data entry validators. Sometimes there may be a requirement for these validators to only validate when certain conditions are met. An example may be if a user checks a checkbox which means that additional fields need to be completed. In this situation the additional input text field validators would have their Enabled property set to false. When the user checks the checkbox the additional input text field validator needs to be enabled.
Usage
// validation is initially off for all the additional fields
var options =
{
"initialValidationState":0,
"inputsToToggleValidationSelector":".additional"
};
$("form:checkbox").aspNetValidatorToggler(options);
Options
| bindType | String | Default: “click” |
|---|---|---|
| The name of the event to bind to and trigger the toggling of the validators state | ||
| initialValidationState | Number | Default: 1 |
| 1 indicates that the validators are initially enabled and 0 that they are disabled. For example, if the validators are initially enabled then the first toggle event will disable the validators. | ||
| inputsToToggleValidationSelector | String | Default: null |
| A selector that identifies input elements whose validators state will be toggled when the toggle event is triggered. If no selector is provided all validators have their state toggled. | ||
Download
The download contains an ASP.NET Web Application project demonstrating the usage of the plugin with ASP.NET validators.
| ASP.NET Validator toggler jQuery Plugin v0.1 | Download |