Trying to use ASP.NET Custom validator for conditional validation
-
Hello, I have a radio button list control on my ASP.NET web form for selecting the payment method (Credit Card, Cheque or Cash), And a credit card detail submission area for entering the credit card details if the user chose Credit Card as the payment method. The credit card detail entering area has a radio button list control for selecting Credit Card type (AMEX, Master or VISA), a text box for entering the credit card number and a drop down list for selecting the credit card expiry month as shown below
Credit Card Cheque Cash / Other American Express Master Card VISA Month 01 02 03 04 05 06 07 08 09 10 11 12
I am trying to validate my webform so that, IF and ONLY IF the user select the first option (Credit Card) for payment type, Then the user must ALSO select the credit card type (rdCCType), then enter credit card number (txtCCNumber) and also select credit card expiry month (ddlCCExpiryMonth) I have absolutely no idea how to accomplish this and where to start. Please show me how to do this using ASP.NET validation controls. Thank you.
-
Hello, I have a radio button list control on my ASP.NET web form for selecting the payment method (Credit Card, Cheque or Cash), And a credit card detail submission area for entering the credit card details if the user chose Credit Card as the payment method. The credit card detail entering area has a radio button list control for selecting Credit Card type (AMEX, Master or VISA), a text box for entering the credit card number and a drop down list for selecting the credit card expiry month as shown below
Credit Card Cheque Cash / Other American Express Master Card VISA Month 01 02 03 04 05 06 07 08 09 10 11 12
I am trying to validate my webform so that, IF and ONLY IF the user select the first option (Credit Card) for payment type, Then the user must ALSO select the credit card type (rdCCType), then enter credit card number (txtCCNumber) and also select credit card expiry month (ddlCCExpiryMonth) I have absolutely no idea how to accomplish this and where to start. Please show me how to do this using ASP.NET validation controls. Thank you.
You make validation groups, and assign the controls in the credit card code to use the validation group for it. Then assign the submit button that triggers the validation group with the same group. Example: http://www.aspsnippets.com/Articles/Validate-Multiple-Validation-Groups-with-one-Button-in-ASPNet.aspx[^]
-
Hello, I have a radio button list control on my ASP.NET web form for selecting the payment method (Credit Card, Cheque or Cash), And a credit card detail submission area for entering the credit card details if the user chose Credit Card as the payment method. The credit card detail entering area has a radio button list control for selecting Credit Card type (AMEX, Master or VISA), a text box for entering the credit card number and a drop down list for selecting the credit card expiry month as shown below
Credit Card Cheque Cash / Other American Express Master Card VISA Month 01 02 03 04 05 06 07 08 09 10 11 12
I am trying to validate my webform so that, IF and ONLY IF the user select the first option (Credit Card) for payment type, Then the user must ALSO select the credit card type (rdCCType), then enter credit card number (txtCCNumber) and also select credit card expiry month (ddlCCExpiryMonth) I have absolutely no idea how to accomplish this and where to start. Please show me how to do this using ASP.NET validation controls. Thank you.
you can make the validation group in every radio button and also with in Drop down list. IF you when submit button click check the every validation group, if any validation throw false your button not working. I hope Validation Group help solve your problem.