Saturday, April 20, 2013

Making sure at least one checkbox is checked


Html Code  Multi Array value

<input type="checkbox" name="region_id[]" value=""  id="region_id"/>



JavaScript code 


function check_region(){
count = 0;
for(x=0; x<document.form1.region_id.length; x++){
if(document.form1.region_id[x].checked==true){
count++
}
}

if(count==0){
alert("You must choose atleast One Region ");
document.form1.jdate.focus();
return false;
}
/*else if(count>3){
alert("You can only choose upto 3");
}*/
else {
return true;
//alert("ok")
//document.form1.fullname.focus();
}
}

No comments:

Post a Comment