Skip to main content
Known Participant
May 6, 2026 1:32 PM UTC
Answered

How to clear content of for field when set to hidden

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;

};


 

    try67
    try67Correct answer
    Community Expert
    May 6, 2026 3:08 PM UTC

    Use this:

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

      two.value = "";

    }

    2 replies

    try67
    Community Expert
    try67Community ExpertCorrect answer
    Community Expert
    May 6, 2026 3:08 PM UTC

    Use this:

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

      two.value = "";

    }

    Translate
    Known Participant
    May 6, 2026 3:20 PM UTC

    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;

     

    Translate