Skip to main content
Participating Frequently
November 1, 2023
Question

If radio button is selected then text field shows up

  • November 1, 2023
  • 3 replies
  • 2120 views

hello,

I'm brand new to JavaScript and Adobe form fields,
I create a form with five radio buttons "Option 1, "Individual," "Option 2, "Couple," "Option 3, "Single parent" "Option 4, "Family" "Option 5, "Waives" and a text field" (please specify)".
I want the form to show a text field (please specify)", (and become required if possible) if someone selects the radio button option 5 "Waives", but I don't want it to appear as an option if he chose “Option 1,2,3,4,”.

What is the best way to do this?

Thanks in advance

 

    This topic has been closed for replies.

    3 replies

    Bernd Alheit
    Community Expert
    Community Expert
    November 22, 2023

    This one liner will not work.

    Nesa Nurani
    Community Expert
    Community Expert
    November 1, 2023

    Let's say radio buttons are named "Group1", (change to your actual name) use this as custom calculation script of text field:

    event.target.display = this.getField("Group1").valueAsString === "Waives" ? 0 : 1;
    event.target.required = this.getField("Group1").valueAsString === "Waives" ? true : false;

    Participating Frequently
    November 14, 2023

    thks for your answwer, it not working 😞  let try another trategy,

    I have create a form with one check box buttons and one text field..

    the checkbox field named "checkBox" and a text field named "textField" , I want to be abble to show the text field when the checkbox is checked and hide it when it's unchecked.

     

    thansk in advance

     

    Nesa Nurani
    Community Expert
    Community Expert
    November 14, 2023

    As Mouse Up action of checkbox:

    this.getField("textField").display = event.target.value == "Off" ? display.hidden : display.visible;

    kglad
    Community Expert
    Community Expert
    November 1, 2023

    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">