hello,
I m trying to check if user has selected at least one checkbox and give an alert for select atleast one.
the checkbox in the forms are dynamics depends up on data received from database
for ex.
user has to select at least one customer to process ahead .
i have written below code to validate :
alert_flag=0;
for(j=0;j<count0;j++)
{
//alert(document.frm.elements[j].name);
//alert("cust_id["+i+"]");
if(document.frm.elements[j].name=="cust_id["+i+"]")
{
i++;
if(document.frm.elements[j].checked)
{
alert_flag=1;
break;
}
}
}
if(alert_flag==0)
{
alert("Please select At least Customer ");//At least one record must be checked for delete
return false;
}
j counter check for all the element and i counter increase only when checkbox found.
this doesn't work sometime Though user has checked one of them.It gives the alert "Please select At least Customer"
don't know how but it not happens all the time.
i have displayed a list of all customer in page so there can be more elements.