I've a page with few textboxes and their corresponding validators (ASP.NET validator).
And clearly I can validate each of those validators from javascript by calling the function
Page_ClientValidate("myvalidators")
where myvalidators is my validators group name
The same way I can validate a specific validator using
ValidatorEnable(Page_Validators[0]);
which only checks that specific validator
But my question is how can I find or figure out the control (Textbox) which is connected with that specific validator.
That means a function which can return all the controls with a failed validator.
Or more clearly, the function should return a collection object of controls where there corespnding validator is failed.
More description added
My scenario is to highlight the parent div of the textbox where the validator failed. So if I get the texbox control object or the control arrays, I can just take each of its parent div and can highlight it.
Page_Validators array returns the same metadata that we receive in custom validation function. It means that you can receive the associated control identifier something like this Page_Validators[0].controltovalidate
.
<script>
$(function () {
// process all validators and their controls
$.each(Page_Validators,function (i,v){
if(v.controltovalidate) {
$("#"+v.controltovalidate);
}
});
});
</script>