Disable ASP.NET validators with JavaScript

后端 未结 6 1241
小鲜肉
小鲜肉 2020-12-05 04:23

Does anyone know how to disable an ASP.NET validator using JavaScript? I\'m using javascript style.display = \'none\' to disable parts of a web page. However these disabled

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 05:08

    Per Glenn G's comment above, I would use

    myVal.enabled = false; 
    

    to disable the validator instead of

    ValidatorEnable(myVal, false); 
    

    Here's what I experienced: Both snippets worked fine on my 2003 server with .net framework 2.0. However, on server 2008 R2 with .net framework 4.0 (I'm not sure which is causing the issue), I was getting unintended behavior with "ValidatorEnable". There are tabs (usercontrols) on my page and when I would leave the tab that was calling "ValidatorEnable", it was temporarily disabling validators on the next tab (even though code was not being called to disable them) until the next postback.

提交回复
热议问题