How to get the list of validators for a control.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to get the list of all the validators that are attached to a
control ( for example Textbox) using client side javascript.

Thanks.
 
Yes, client-side validators are acutally <span tags so you should be able to
do something like:

var spans = document.getElementsByTagName("span");
for (var i = 0; i < spans.length; ++i){
var span = spans;
var controlToValidate = span.exclude ||
span.getAttribute('controltovalidate');
if (controlToValidate != null && controlToValidate ==
'<%=TEXTBOXNAME.ClientId%>'){
alert(span);
}
}

span will them be a DOM object which points to a valiadator for TEXTBOXNAME


Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top