Hide subform if text field is null | Community
Skip to main content
Level 7
January 15, 2013
Solved

Hide subform if text field is null

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
radzmar
radzmarAccepted solution
Level 10
January 15, 2013

Hi,

try this script:

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

5 replies

mdawn50Author
Level 7
January 21, 2013

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

Translate
mdawn50Author
Level 7
January 15, 2013

It works. Thank you.

MDawn

Translate
radzmar
radzmarAccepted solution
Level 10
January 15, 2013

Hi,

try this script:

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

Translate
mdawn50Author
Level 7
January 15, 2013

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

Translate
Level 5
January 15, 2013

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

Translate