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();
}
精彩评论