Requiring all options to be selected

This example uses the choice validator to ask user to accept all the terms and conditions in order to continue.
<form id="demoForm" method="POST">
<input class="mr2" type="checkbox" name="agreements[]" value="terms" /> I have read and agree to the Terms
<input class="mr2" type="checkbox" name="agreements[]" value="privacy-policy" /> I accept the Privacy Policy ...
</form>
<script>
document.addEventListener('DOMContentLoaded', function(e) {
FormValidation.formValidation(document.getElementById('demoForm'), {
fields: {
'agreements[]': {
validators: {
choice: {
min: 2,
max: 2,
message: 'Please check all agreements to continue'
}
}
},
},
plugins: {
...
},
});
});
</script>
Requiring all options to be selected

See also