开发者

Does javascript ValidatorEnable still supports in ASP.Net 4.0?

开发者 https://www.devze.com 2023-03-07 04:01 出处:网络
I would like to disable a RequireFieldValidator control by a certain condition. I have tried this code

I would like to disable a RequireFieldValidator control by a certain condition.

I have tried this code

function doSomething()
{
  var myVal = document.getElementById('RequiredFieldValidator1');
  ValidatorEnable(myVal, false); 
}

The result is, this function make the validation message disappear but the validation still fire 开发者_如何学JAVAwhen we post-back.


Sorry for bothering, i have just found the solution to my own question. This code is truly disable the client-side validator but i still need to set the disable post-back validator on my own page by the following code.

public override void Validate()
{

    RequiredFieldValidator1.Enabled = !RadioButton1.Checked;
    // Now perform validation
    base.Validate();
} 
0

精彩评论

暂无评论...
验证码 换一张
取 消