I'm using old fashioned ASP.NET validation (ugh) for a checkout process. I have a checkbox -"I'll call with my credit card details"-. If checked I need to disable the required field validator and cc validator for the credit card number both on the client and on the Postback.
How do it do it?
You can disable the validators client-side (in javascript):
function disable(validatorId)
{
var validator = document.getElementById(validatorId);
ValidatorEnable(validator, false);
}
Where validatorId is the clientID of the validator to be disabled. See this page for a complete example.
You can disable the validators server-side:
MyFieldValidator.Enabled = MyCheckBox.Checked
Page.Validate()
If Page.IsValid Then
'stuff
end if
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With