I have a table with a list of materials and a check to the side are part of a form, what I want to do is not send my form until all the fields are filled with my check, because so far the form but it is sent even though I have not selected any material when I have not clicked on my check.
To validate a checkbox I need the name property, but the detail and my problem is that in the name I have a variable that fills my table and in turn that variable I use to send it to another page
name = ''
and I do not know how to change that.
function valida(document)
{
if (document.check.value =="")
{
alert("Indique el material de la cotización o pedido.");
document.check.focus();
return false; }
}
<?php
$m=mysql_query("select id, material from material");
?>
<?php
if (!isset($_GET['id'])) {
?>
<table class='mat' border='1'>
<tr><td>MATERIAL</td><td>Seleccione</td></tr>
<?php
while ($m1=mysql_fetch_array($m)) {
?>
<tr><td><?php echo $m1[1];?></td><td><input type='checkbox' name='<?php echo "mat".$m1[0]?>' id='check' value=''/></td></tr>
<?php
}
?>
</table>