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
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
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
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;
}
}