Skip to main content
Inspiring
October 28, 2023
Answered

Check both checkboxes to make text field visible

  • October 28, 2023
  • 2 replies
  • 1884 views

I have two checkboxes - Checkbox1 and Checkbox2.  I also have a text field - TextField1.  I would like TextField1 to become visible only if both Checkbox1 and Checkbox2 are checked.  If either of the two checkboxes is unchecked, I would like TextField1 to remain hidden.  Thanks for any assistance with either javascript or a calculation script.

    This topic has been closed for replies.
    Correct answer Nesa Nurani

    Use this as 'Custom calculation script' of text field:

    var c1 = this.getField("Checkbox1").valueAsString;
    var c2 = this.getField("Checkbox2").valueAsString;
    event.target.display = (c1 !== "Off" && c2 !== "Off") ? 0 : 1;

    2 replies

    Nesa Nurani
    Nesa NuraniCorrect answer
    Community Expert
    October 28, 2023

    Use this as 'Custom calculation script' of text field:

    var c1 = this.getField("Checkbox1").valueAsString;
    var c2 = this.getField("Checkbox2").valueAsString;
    event.target.display = (c1 !== "Off" && c2 !== "Off") ? 0 : 1;
    BrianG934Author
    Inspiring
    October 28, 2023

    Thank you.  Works perfectly.  I am also trying to do the same thing with a button (both checkboxes need to be checked in order to make the button visible).  Your code works for text fields, but not for buttons.  Could you also help with that.  Thanks.

    Nesa Nurani
    Community Expert
    October 28, 2023

    If it's the same checkboxes you can add this part to the script, just change "Button1" to your actual button field name:

    this.getField("Button1").display = (c1 !== "Off" && c2 !== "Off") ? 0 : 1;

     

    kglad
    Community Expert
    October 28, 2023

    assuming acrobat 

     

    in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

    p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



    <"moved from using the community">