None of the above checkbox

Is there a way to have a “none of the above” checkbox that would uncheck all other options? I tried using the solution posted here:

but I’m getting a syntax error.

I pasted the following snippet:
$(‘.gfield-choice-input[value=“none”]’).on(‘change’, function() {
if ( $(this).is(‘:checked’) ) {
$(this).parent().siblings().find(‘.gfield-choice-input’).each( function() {
this.checked = false;
});
}
});

$(‘.gfield-choice-input:not([value=“none”])’).on(‘change’, function() {
if ( $(this).is(‘:checked’) ) {
$(this).parent().siblings().find(‘.gfield-choice-input[value=“none”]’).prop(‘checked’,false);
}
});

I get this error:
syntax error, unexpected ‘(’, expecting variable (T_VARIABLE) or ‘{’ or ‘$’

That’s a jQuery snippet, but your error message sounds like a PHP error. Did you add this to an HTML field in the form, or via PHP? Can you explain how you added it?

I added it to the functions.php section

I also just tried to add it to an html field, but that doesn’t work

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.