Copy link to clipboard
Copied
Hi Adobe Community,
I would like a text field to populate a text hint when I select a particular option from a pull down menu. I want the text hint to appear grey when that option is selected and I want it to disappear once the user starts to type in the text field (and return in grey if the text field is left blank). And when the user starts to type in the text field, I want the text to be black. If the user selects any other option in that pull down menu, the text hint shouldn't appear at all.
I'm pretty sure I need to do on focus/on blur events in the text field, similar to what I have done for a Check Box, but I just can't seem to come up with the right script to make it happen for a drop down menu instead. I'm also guessing the 'default' verbiage might need to be removed since this text field has no default text? Thanks in advance!!
// On focus, Run a Javascript //
if (event.target.value==event.target.defaultValue) {
event.target.value = "";
event.target.textColor = color.black;
}
// On Blur, Run a Javascript //
if (event.target.value=="") {
var ckbox = this.getField("Delivery");
if (ckbox.value === "Off") {event.target.defaultValue = "";}
else if (ckbox.value === "Recover") {event.target.defaultValue = "Order#";}
else if (ckbox.value === "Ship") {event.target.defaultValue = "Company Name";}
event.target.value = event.target.defaultValue;
event.target.textColor = color.ltGray;
}
Copy link to clipboard
Copied
Keep the On Focus script, but remove the On Blur one. Instead, use this as the custom Validation script of the dropdown (I assumed the text field is called "Address", since you didn't specify its actual name):
if (event.value=="Yes") {
this.getField("Address").defaultValue = "Provide the full address";
this.getField("Address").textColor = color.ltGray;
} else this.getField("Address").defaultValue = "";
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Which value is supposed to turn the text grey?
Copy link to clipboard
Copied
@PDF Automation Station Well, this text field won't have have a default value, but normally when the user types in it, the text is black and that's good. I only want the text to be grey when one particular selection is made in one drop down menu. The grey text is a hint for what information needs to be put in the text field since that drop down option was selected. And I want the grey hint text to disappear as soon as the user starts writing (in which case, the user's text will be black). So the grey text in the text field would say something like "Please provide XYZ here..." Thanks!
Copy link to clipboard
Copied
"I only want the text to be grey when one particular selection is made" That's what I'm asking you. What is the selection?
Copy link to clipboard
Copied
@PDF Automation Station Ah, it's a selection in a drop down menu. Only one selection (of 3) will have this functionality. The other 2 selections in that drop down menu shouldn't do anything in the text field.
Copy link to clipboard
Copied
One more time: What is the text of the selection?
Copy link to clipboard
Copied
@PDF Automation Station You're looking for the actual words I want to use? Sorry! 🙂 In the drop down menu, the text will just be "Yes" and the hint text to appear in the text box would be "Provide the full address".
Copy link to clipboard
Copied
Keep the On Focus script, but remove the On Blur one. Instead, use this as the custom Validation script of the dropdown (I assumed the text field is called "Address", since you didn't specify its actual name):
if (event.value=="Yes") {
this.getField("Address").defaultValue = "Provide the full address";
this.getField("Address").textColor = color.ltGray;
} else this.getField("Address").defaultValue = "";
Copy link to clipboard
Copied
Thanks @try67 ,
Would you be able to help me tweak a couple things?
Right now, when I reset the form, the "Provide the full address" grey hint text verbiage is visible in the text field, even without "Yes" being selected in the drop down field. Also, from a form reset (and the grey hint text is already there), if I select "No" in the drop down menu, the grey hint text still doesn't disappear. I only want to see that verbiage when "Yes" is selected.
And when "Yes" is selected, and the user starts to type something in the text field, the grey hint text does disappear as desired, but if the user ends up deleting what they wrote and leaving that text field blank, the grey hint text doesn't come back. When "Yes" is selected, I would want the text field to have that grey hint text so long as nothing is written in the text field yet.
Fingers crossed that this is doable 🙂 Thanks in advance for your help!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@try67 This is exactly what I needed, thank you so much for your time!
Copy link to clipboard
Copied
Hope you are doing well.
Thanks for taking the time and letting us know that it worked for you.
Regards,
Souvik.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now