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

Text Field Populates Text Hint When Item Selected from Drop Down Menu

New Here ,
May 13, 2025 May 13, 2025

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;
}

 

TOPICS
Create PDFs , JavaScript , PDF , PDF forms
460
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
2 ACCEPTED SOLUTIONS
Community Expert ,
May 13, 2025 May 13, 2025

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 = "";

 

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
Community Expert ,
May 15, 2025 May 15, 2025

It required a bit more complex solution... See attached.

 

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
Community Expert ,
May 13, 2025 May 13, 2025

Which value is supposed to turn the text grey?

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 ,
May 13, 2025 May 13, 2025

@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!

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 ,
May 13, 2025 May 13, 2025

"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?

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 ,
May 13, 2025 May 13, 2025

@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.

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 ,
May 13, 2025 May 13, 2025

One more time:  What is the text of the selection?

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 ,
May 13, 2025 May 13, 2025

@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". 

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 ,
May 13, 2025 May 13, 2025

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 = "";

 

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 ,
May 14, 2025 May 14, 2025

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!

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 ,
May 15, 2025 May 15, 2025

It required a bit more complex solution... See attached.

 

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 ,
May 15, 2025 May 15, 2025

@try67 This is exactly what I needed, thank you so much for your time!

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
Adobe Employee ,
May 15, 2025 May 15, 2025
LATEST

Hi @Stevie38923324rffg,

 

Hope you are doing well. 

 

Thanks for taking the time and letting us know that it worked for you.


Regards,
Souvik.

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