I tried using JavaScript samples that I found here and other places. The problem is that I am using a Table control working at the server, so the JavaScript I was using does not recognizes the checkboxes which are server side as well. I kept getting the same error message over and over. I got 20 rows with 2 columns each, one for the checkbox and one for a statement that the user has to validate by checking the box before they can submit. The user has to physically check each box. If any checkbox is not checked, then I would like to sees a popup message saying they must check all boxes, Else I am doing a redirect to another page, of course all this on the button click event. This all on Visual Studio 2010, using C#, the back-end is SQL Server.
Here a sample of the JS I was using:
function checkCheckBoxes() {
if (document.frmTest. CheckBox1.checked == false &&
document.frmTest. CheckBox2.checked == false &&
document.frmTest. CheckBox3.checked == false &&
document.frmTest. CheckBox4.checked == false &&
document.frmTest. CheckBox5.checked == false &&)
{
alert ('You must check all the checkboxes!');
return false;
}else{
return true;
}
}
then,
<form onsubmit="return checkCheckBoxes();" action="">
<input type="checkbox" name=" CheckBox1" value="1">
<input type="checkbox" name=" CheckBox2" value="2">
<input type="checkbox" name=" CheckBox3" value="3">
<input type="checkbox" name=" CheckBox4" value="4">
<input type="checkbox" name=" CheckBox5" value="5">
<input type="submit" value="Submit!" />
</form>
But I realized that the checkboxes can't be server control but JavaScript controls. Thanks.
Repeater?