Copy link to clipboard
Copied
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
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);
Copy link to clipboard
Copied
Reaching out again to anyone for any assistance on this.
Thanks
Copy link to clipboard
Copied
Yes, it's possible. What type of fields are they, and what are the conditions to show/hide the text fields?
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
Use this code as the custom validation script of the first field:
this.getField("Target field name").display = (event.value=="") ? display.hidden : display.visible;
Copy link to clipboard
Copied
In your example above, is the Target Field Name the one that would be hidden?
Copy link to clipboard
Copied
Yes.
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
If "A" is checked as read-only, would that be making the difference in the script not working?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
Thanks try67!... I owe ya a case of beer or something!
Copy link to clipboard
Copied
Do you know how I would do it for the "Filing_Agency" field that just contains the script:
event.value = this.getField(" Agency ").value
Copy link to clipboard
Copied
Try this:
var f = this.getField("Agency");
event.value = (f.valueAsString==f.defaultValue) ? "" : f.valueAsString;
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It should show the value of the Agency field, if it's not the default value. Is that not working?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
try67... any suggestions?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
You don't need to post the same question over and over.
Copy link to clipboard
Copied
Sorry, I thought that is was in the wrong subject And here was more appropriate.