Using Javascript checkbox check validation for check atleast 4 checkbox

How to make validation in multiple checkbox and check onlt one checkbox at submit time then make this validation useful :

   	<script type="text/javascript">
{

var selectedReq = "";
var objChb=document.form1.elements['chk'];
var count=0;
var url;
if(objChb.length > 0)
{
for( i = 0; i < objChb.length; i++ )
{
if ( objChb[i].checked == true )
{
if ( selectedReq == "" )
{
selectedReq = objChb[i].value;
}
else
{

}
count = count +1;
}
}
}
else
{
if(document.form1.chk.checked == true)
{
count=1;
}
else
{
count=0;
}
}
if(count == 5)
{
alert("Please select only 4 option.");
return false;
}
}
</script>

Ebook Download
View all
Learn
View all