Anicho
Anicho

Reputation: 2667

Asp.Net C# invoke single validator

I am having problems trying to invoke just one validator on it own, I know how to call on all validators to perform checks on buttons click events, by using Page.Validate() but how can I invoke lets say mySingledOutValidator I tried mySingledOutValidator.Validate() but that's not gonna work individual controls don't have .validate()

I need the following to be true:

If the above is not possible I do not mind looking into javascript alternatives.
If you can help it would be greatly appreciated.

Upvotes: 2

Views: 1625

Answers (2)

VMAtm
VMAtm

Reputation: 28355

According this article:

function ValidatorValidate(val, validationGroup, event)

With jquery validators:

And in case I wanted to force the validation I should have written:
ValidatorValidate($("#<%= valEncOtherMimeTypeRequired.ClientID %>")[0]);

Upvotes: 2

TheCodeKing
TheCodeKing

Reputation: 19230

You can use Group Validation. You can assign a validator a validationgroup value, and then explicitly validate that group, which can contain 1 or more validators.

Page.Validate("MyGroup");

You can also check the validation status of each validator explicitly using IsValid property, assuming validation has already taken place.

Upvotes: 4

Related Questions