I wrote this function to validate some form-specific radio buttons. As my page is in PHP and I include top and footer includes, the function works when it is in footer.php, but since the function does not apply to all pages, I have to place it individually in the body of the specific pages. When I do this it mysteriously does not work and does not report errors on the console.
$(function(){
$('body').on( 'change', ':radio', function(){
if( $('input[value="3"]:checked').length > 5 ){
alert('Somente 5 opções críticas podem ser marcadas');
$(this).prop({ checked : false });
}
});
});