SisterMargaret wrote But then I read that the checkmark allow multiple selections but it allows user not to select atleast one ( is this true?) |
No it's not true. You can use jQuery, javascript or php to check that at least one checkbox option has been chosen. Below is some sample code using jQuery:
<!DOCTYPE html>
<html>
<head>
<title>Checkbox Validation</title>
<meta charset="UTF-8">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script>
// checkbox validation
$(function(){
$("#select").submit(function(){
var checked = $(".selection:checked").length > 0;
if (!checked){
alert("Please choose at least one option");
return false;
}
});
});
</script>
</head>
<body>
<h2>Please select your options</h2>
<form method='post' id="select" action=''>
<p><input type="checkbox" name="selection[]" class="selection" title="selection" value="Red"/> Red</p>
<p><input type="checkbox" name="selection[]" class="selection" title="selection" value="Yellow"/> Yellow</p>
<p><input type="checkbox" name="selection[]" class="selection" title="selection" value="Green"/> Green</p>
<p><input type="checkbox" name="selection[]" class="selection" title="selection" value="Blue"/> Blue</p>
<p><input type="submit" name="submit" class="submit" value="SUBMIT"></p>
</form>
</body>
</html>