Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Hide field based on another text field

New Here ,
Oct 21, 2017 Oct 21, 2017

Is there a way to hide a text field (or fields) based on if data is entered into another text field? Meaning, a text field is hidden if nothing is entered into another one elsewhere in the form

TOPICS
Create PDFs
10.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Oct 24, 2017 Oct 24, 2017

OK, that's more clear, and easy to solve.

Change this line of code:

if (v!="") values.push(v);

To:

if (v!="" && v!=f.defaultValue) values.push(v);

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 23, 2017 Oct 23, 2017

Reaching out again to anyone for any assistance on this.

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2017 Oct 23, 2017

Yes, it's possible. What type of fields are they, and what are the conditions to show/hide the text fields?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 23, 2017 Oct 23, 2017

They are all just text fields. I would like 2 hidden until another is filled in and exited if that makes sense (unless that's not what you were asking).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2017 Oct 23, 2017

Use this code as the custom validation script of the first field:

this.getField("Target field name").display = (event.value=="") ? display.hidden : display.visible;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 23, 2017 Oct 23, 2017

In your example above, is the Target Field Name the one that would be hidden?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2017 Oct 23, 2017

Yes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2017 Oct 24, 2017

I cannot get the below validation script to work. I'd like to have 2 (maybe 3) text fields hidden until another field is populated. For example: If "A" is empty, "B", "C" & "D" are hidden. If "A" has text entered into it, then B, C & D are visible. I tried the below script with A hiding B but still could not get it to work.

try67  wrote

Use this code as the custom validation script of the first field:

this.getField("Target field name").display = (event.value=="") ? display.hidden : display.visible;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2017 Oct 24, 2017

If "A" is checked as read-only, would that be making the difference in the script not working?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2017 Oct 24, 2017

Yes, of course. If the field is read-only then the validation script for it

will never launch. You need to better explain how you want it to work, I

think...

Do these fields have a calculated value, or one entered by the user?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2017 Oct 24, 2017

Okay... here's what I have and am trying to do...

I have a field called "Address_Combined" that is a read-only field and contains a combination of two other fields, "Address1" and "City_St_Zip" fields. It has a custom calculation script as follows:

var fields = ["Address1", "City_St_Zip"]; 

var values = []; 

for (var i in fields) { 

    var f = this.getField(fields); 

    var v = f.valueAsString; 

    if (v!="") values.push(v); 

event.value = values.join(" ");

Address1 and City_St_Zip fields both contain default text (sample text) and have ON FOCUS and ON BLUR scripts to gray it out and not print. The ON FOCUS & ON BLUR scripts for those are:

// On Focus script:

if (event.target.value==event.target.defaultValue) {

    event.target.value = "";

    event.target.textColor = color.black;

}

// On Blur script:

if (event.target.value=="") {

    event.target.value = event.target.defaultValue;

    event.target.textColor = color.ltGray;

}

My issue is that the Address_Combined is displaying the default text all the time. I would want it blank if the document is opened and nothing entered so if someone wants to view or print it, that text wont show in Address_Combined field.

I have similar issue with a field called "Agency" that contains default text, but does not have the ON FOCUS or ON BLUR. It's just a default text entry. Another field later in the form set to read-on and is called "Filing_Agency"  has the calculation script below to pull the name text from "Agency" but I would like that hidden as well if the form opened or printed with no other data entered. "Filing_Agency" field calculation script is:

event.value = this.getField(" Agency ").value

Not sure if what I want to do is do-able or not, but thanks for any help

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2017 Oct 24, 2017

OK, that's more clear, and easy to solve.

Change this line of code:

if (v!="") values.push(v);

To:

if (v!="" && v!=f.defaultValue) values.push(v);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2017 Oct 24, 2017

Thanks try67!... I owe ya a case of beer or something!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2017 Oct 24, 2017

Do you know how I would do it for the "Filing_Agency" field that just contains the script:

event.value = this.getField(" Agency ").value

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2017 Oct 24, 2017

Try this:

var f = this.getField("Agency");

event.value = (f.valueAsString==f.defaultValue) ? "" : f.valueAsString;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2017 Oct 24, 2017

that hid it, but hides it for good. Can't seem to get it back. I'd like it to show if data is entered elsewhere in the form.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2017 Oct 24, 2017

It should show the value of the Agency field, if it's not the default value. Is that not working?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2017 Oct 24, 2017

ahh yes that DID work when I entered something else. I guess my problem now would be that it needs to display the default text in "Agency" if it isn't changed and other data is entered.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2017 Oct 24, 2017

try67... any suggestions?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2017 Oct 24, 2017

I sent a reply but it seems to have gotten lost...

If you do want to show the default value then go back to the old code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 06, 2021 Jun 06, 2021

Is there a way to hide all the text fields on a page,  depending on if data is entered into another text field?

Lets say I have a text box called "Name Surname". If this text box is blank, all the fields on the page should be hidden.

If I fill in the "Name Surname" box, all the fields on the page become visible.

 

Thanks in advance to anyone for the help

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2021 Jun 06, 2021

You don't need to post the same question over and over.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 06, 2021 Jun 06, 2021
LATEST

Sorry, I thought that is was in the wrong subject And here was more appropriate.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines