Skip to main content
Known Participant
May 6, 2026
Answered

How to clear content of for field when set to hidden

  • May 6, 2026
  • 1 reply
  • 30 views

I have a form where fields completed a basic business card. The fields get pulled find but has the option to place 2 emails. With “Email2” to hidden when “Email” was not used. However, if someone places something in “Email2” but then clears “Email”, “Email2” breaks the long script  already in place.

 

I want the “Email2” field to clear itself when its set to hidden. Is this Possible?

This is what ive already started below:

var one   = this.getField("Email");
var two   = this.getField("Email2");

if (one.value!=""){
  two.display=display.visible;
};

if (one.value==""){
  two.display=display.hidden;

};


 

    Correct answer try67

    Use this:

    if (one.value==""){
      two.display=display.hidden;

      two.value = "";

    }

    1 reply

    try67
    Community Expert
    try67Community ExpertCorrect answer
    Community Expert
    May 6, 2026

    Use this:

    if (one.value==""){
      two.display=display.hidden;

      two.value = "";

    }

    Known Participant
    May 6, 2026

    The way it was written did not work however flipping the value and display lines worked. Not sure why this is but below did the trick.

     

    if (one.value==""){

      two.value = "";
      two.display=display.hidden;