!hello,
i have a number of checkboxes generated with PHP. There is a validation button. I want to prevent the user to valid the form without checking at least 1 checkbox.
I have this code
var checkboxes = document.getElementsByName('date[]');
var btn = document.getElementById('Submit');
date.onchange = function(){
for (var i=0;i<checkboxes.length;i++)
{
if(checkboxes[i].checked)
{
btn.disabled = false;
}
else
{
btn.disabled = true;
}
}
}
<form>
....
<table>
<tr id="{{ cpt }}">
<td><input type="checkbox" class="date" id="date" name="date[]"
checked value="{{ jdv.day }}"></td>
<td>{{ jdv.day }}</td>
</tr>
</table>
</form>
But it only work for the first checkbox!
can you help me?
Thanks