Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Hide subform if text field is null

Avatar

Level 7

I have this script on the change event of a text field:

if ((this.rawValue != "null") || (this.rawValue != ""))
{
checkBoxThree.presence = "visible";
}

else
{
checkboxThree.presence = "hidden";
}

It is correctly displaying the checkBoxThree subform when data is entered in the text field.

However, if the user goes back and deletes the text, I would like the subform to become hidden and it isn't. How should I change the script to accomplish this?

Thanks,

MDawn

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

try this script:

checkBoxThree.presence = xfa.event.fullText.length == 0 ? "visible" : "hidden";

View solution in original post

5 Replies

Avatar

Level 5

Hi,

Change your if statement as follows it would work..

if (this.rawValue != null)

checkBoxThree.presence = "visible";

}

else

{

checkboxThree.presence = "hidden";

}

Please place the code on the Exit event of the textfield then it will work.

Vjay

Avatar

Level 7

I tried the changes you suggested and also noticed I had checkBoxThree mis-capitalized in the 'else' statement. I fixed all that and it still doesn't hide the subform  if the user deletes the content from the text field.

Thanks,

MDawn

Avatar

Correct answer by
Level 10

Hi,

try this script:

checkBoxThree.presence = xfa.event.fullText.length == 0 ? "visible" : "hidden";

Avatar

Level 7

Hello,

This script works perfectly and I was able to incorporate it into my form. Now the business owners want me to keep the user from submitting the form if the checkbox is visible and unchecked.

I can get the checkbox to be mandatory when visible, but am having trouble getting the checkbox to be non required when hidden.

Thanks,

MDawn