Skip to main content
Participant
May 6, 2026
Answered

How to clear content of for field when set to hidden

  • May 6, 2026
  • 1 reply
  • 11 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 Miguel29015202vlzl

    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;

     

    1 reply

    try67
    Community Expert
    Community Expert
    May 6, 2026

    Use this:

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

      two.value = "";

    }

    Miguel29015202vlzlAuthorCorrect answer
    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;