Dynamically enable a validator?

A

antonyliu2002

I am moving from Java to ASP .NET. Many .NET stuffs remain new to me.

I am wondering if it is possible to dynamically/programmatically enable
a validator.

Suppose that I have the following in my Web application:

Card Type:
o Master
o Visa
o Amex

Card Number:
___________________

If the user enters the card number, but forgets to select a card type,
I want to warn him that he must select a card type.

In other words, the RadioButtonList control validation of card type is
not required unless a valid card number is supplied.

Suppose the card number is validated with a RegularExpressionValidator
and the card type is validated with a RequiredFieldValidator.

Is it possible to do something like the Sub below?

Sub CardTypeValidator(sender As Object, args As
ServerValidateEventArgs)
If CardNumberValidator.IsValid() Then
//Enable CardTypeValidator here
End If
End Sub

I have not tried this. I want to know a little more before I give it a
shot. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top