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'); 
}
});
});
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Commentaires
Inline Feedbacks
View all comments