In my case I needed to show and hide an element with a checkbox to ensure GDPR compliance. Then came the question: how to prevent the validation of a form based on a checkbox?
Checkbox hide and show with Jquery
$(document).ready(function() {
$("#RGPD").click(function() { //ID of checkbox
var checked = $(this).is(':checked');
if (checked) {
$(".button-send-form").show(); //class of the element to display
console.log('checked');
} else {
$(".button-send-form").hide(); //class of the element to hide
console.log('unchecked');
}
});
});