Can a checkbox in Contact Form 7 be disabled?

Can a checkbox in Contact Form 7 (WordPress plugin) be disabled?

I have a group of 5 checkboxes, and I want one to be there, but disabled (not clickable, not selected).

Read More

How to do it?

Related posts

Leave a Reply

3 comments

  1. Add an id to your to your checkbox. It will look something like this, it is important that the id is after the variable as shown below.

    [checkbox variable  id:disablethis "variable"]
    

    This will put the id “disablethis” on the span tag that surrounds your checkbox (input) that you are trying to disable. Then we can simply find that span and disable all of the inputs within it like so. Put this at the bottom of your form/page.

    <script>
    $("#disablethis :input").attr("disabled", true);
    </script>
    
  2. Thanks a million ImTheMechanic! I was looking for a few days how to reference the checkbox and set its state (checked or unchecked).
    I had to put :input after the id.
    I could never have guessed!

    I did it like this:

    if (dayNameB == "zaterdag") {
            $("#brengtijdzat").show();
            $("#brengtijdzat :input").prop("checked", true);
            $("#brengtijd").hide();
            $("#brengtijd :input").prop("checked", false);
        }`
    

    Thanks!