How would I add javascript validation to make sure that at least one of the items is checked?
Select from courses below:
<ul id="class_prices">
<li>
<input onclick="update()" name="lbsm" id="lsbm" type="checkbox" value="lbsm">
<label>Law & Business Study Material ($59.00)</label>
</li>
<li>
<input onclick="update()" name="tsm" id="tsm" type="checkbox" value="tsm">
<label>Trade Study Material ($59.00)</label>
</li>
<li>
<input onclick="update()" name="lbepc" id="lbepc" type="checkbox" value="lbepc">
<label>Law & Business Exam Preperation Class ($50.00)</label>
</li>
<li>
<input onclick="update()" name="tepc" id="tepc" type="checkbox" value="tepc">
<label>Trade Exam Preperation Class ($50.00)</label>
</li>
</ul>
</td>
<td><h2>$<span id="coursetotal"></span></h2></td>
</tr>
Here is javascript code that I have, which does not work.
<script type="text/javascript">
function valthisform() {
var chkd = document.form1.lsbm.checked || document.form1.tsm.checked|| document.form1.lbepc.checked|| document.form1.tepc.checked
if (chkd == true) { } else { alert ("please check a checkbox") }
}
</script>
I will appreciate your feedback.