tags:

views:

80

answers:

2

I have Checkboxlist and i can't give it required field validator or custom validator. it gives me runtime exception.

Language : Vb.net with asp.net

+1  A: 

no cannot apply required field validator on the checkbox list

but you can use custom validator to validate it

for the custom validator to work you have to create your own function on server or client side for validation and one more thing when you are using custom validator there no need to pass value in the controltovalidate property

Pranay Rana
I tried custom validator but with controltovalidate prperty. i will check without it.
Amr Elnashar
if you are using customvlidator than no need to set controltovalidate property
Pranay Rana
A: 

Its working and here is the code

function CheckBoxListValidator(source, arguments) {
            var Control;
            Control = document.getElementById("CKlistVehicleBodies").getElementsByTagName("input");
            var check = false;
            if (eval(Control)) {
                for (var i = 0; i < Control.length; i++) {
                    if (Control[i].tagName == 'INPUT') {

                        if (Control[i].checked) {
                            check = true;
                        }
                    }
                }
                if (!check)
                    arguments.IsValid = false;
                else
                    arguments.IsValid = true;
            }
        }
Amr Elnashar