Alex Rivera | Logout

disable asp.net validator using jquery

Asked 2009-10-29T20:22:00.063
15

I am trying to disable validators using jquery.

I have already looked Disable ASP.NET validators with JavaScript and couple of others doing the same.

It seems ot be working but its breaking.

My code:

$('.c_MyValdiators').each(function() {

    var x = $(this).attr('id');
    var y = document.getElementById(x);
    ValidatorEnable(y[0], false);
});

I get Error: val is undefined [Break on this error] val.enabled = (enable != false);\r\n

Alternatively if I use

$('.c_MyValdiators').each(function() {
    ValidatorEnable($(this), false); OR ValidatorEnable($(this[0]), false);
  });

I get Error:

val.style is undefined [Break on this error] val.style.visibility = val.isvalid ? "hidden" : "visible";\r\n

Any idea or suggestions?

Edit
Report

1 Answer

6

I just stumbled upon your Question [a year later]. I too wanted to disable all validators on a page using JQuery here is how I handled it.

$('span[evaluationfunction]').each(function(){ValidatorEnable(this,false);});

I look for each span on the page that has the evaluatefunction attribute then call ValidatorEnabled for each one of them.

I think the $('this') part of your code is what was causing the hickup.

answered 2010-10-26T15:03:27.933

Your Answer