Copy link to clipboard
Copied
Hello everyone. I was wondering if there was a way to make a label viewable in normal mode for a PDF text field form. I am making my PDF a form with a fillable text box in it. Well, I'd like the box name to show up when someone opens the PDF, not just if they only go into the edit form view. I hope I'm making sense. So far, the only thing I can think of is making a Button with the label above the fillable text box or make the text box a combo box. However, with a combo box, I can't edit how the text will look when it's typed in. Right now, though, when a person opens the PDF normally, the highlighted fillable text boxes show up but not the labels with them even though I have names entered in on Name and Tooltip.
Any suggestions?
One thing you can do is set up a custom Format script for a text field that is:
// Custom format script for text field
if (!event.value) event.value = event.target.name;
This will display the field name in the field when the field is blank. The problem with this approach is it precludes easily using any of the built-in formats that you may want to use (Number, ZIP code, etc.). You still can, but it requires more scripting.
Copy link to clipboard
Copied
So what should happen when the user enters text in the field? Should the field name still be visible somehow?
Copy link to clipboard
Copied
No. I want the label to disappear when the user starts typing in text.
Copy link to clipboard
Copied
One thing you can do is set up a custom Format script for a text field that is:
// Custom format script for text field
if (!event.value) event.value = event.target.name;
This will display the field name in the field when the field is blank. The problem with this approach is it precludes easily using any of the built-in formats that you may want to use (Number, ZIP code, etc.). You still can, but it requires more scripting.
Copy link to clipboard
Copied
Oh my gosh, THANK YOU!! I did what you said after searching how to do custom messages. I didn't even know you could do that in PDF. I wish it was easier than using Java Script. Not a lot of people know JS. It'd be nice if they offered an area where you can type in a custom message if you want rather than having to do JS if you don't like the pre-made messages already.
Again, thank you so much for your help!! You need to put the text field value in quotations, but other than that, the code was perfect!
Copy link to clipboard
Copied
You need to put the text field value in quotations...
I'm not sure what yuo mean by that. Can you elaborate?
Copy link to clipboard
Copied
Hmm. I hope you can help with this quick question, too. I have an optional text box that users can type text in if they want to, but they don't have to. How do I get it so that if they type something in the box, it will show up when they print it, but if they don't put anything in the text box, the label/custom message doesn't show up in the text box when printing? I tried Visible but Hide When Printing, but that made it so that even if the user typed in text, it wouldn't show up when they printed it off.
Copy link to clipboard
Copied
That requires more scripting. Change the previous script to:
// Custom format script for text field
if (!event.value) {
event.value = event.target.name;
event.target.display = display.noPrint;
} else {
event.target.display = display.visible;
}
Copy link to clipboard
Copied
Okay, I went to type something in when testing it, and now the label won't come back up again, even though I deleted all the text. It looks like it did before I had the label/custom message on it. Any way to get the label to show up on the PDF file no matter what (except when user is typing something in) but doesn't print off at all? If they typed text into the text box, I want that to show up. But if they don't, I don't want anything to show up when it's printed. However, I would still like the label to be visible in the PDF file, if that all makes sense. I hope I'm explaining it well.
Copy link to clipboard
Copied
I hope this is possible. Basically, only print text field form if there is fillable text inside of it.
Copy link to clipboard
Copied
What I posted works for me. I'd be happy to take a look at your form if you emai lit to me. My address is in my profile.
Copy link to clipboard
Copied
I asked one of our IT guys to help, but if he can't figure it out, I'll sure e-mail it to you. Thank you so much for ALL your help!! Yeah, basically, the label is not... wait. Was I supposed to put that code you entered the 2nd time after the first one? I thought it was just supposed to replace the original script you first posted. Basically, the label is not showing up again, like it did before I put in that first code the first time.
Copy link to clipboard
Copied
Yes, the second script should replace the first. Feel free to send the file.
Copy link to clipboard
Copied
Oh my gosh... I feel like such a dork!! I took a fresh look at it this morning, and the ONLY mistake I had was that I put the ending quotations in the wrong spot! I forgot to include (Optional) inside the quotations for the label!
I had this: if (!event.value) event.value = "Company Information" (Optional);
Instead of this: if (!event.value) event.value = "Company Information (Optional)";
Oi!! That was it! lol! I'm sorry about that. And yes, without those quotations, my text form fields don't work. I hadn't seen your message before (until now) asking for me to clarify that. I'm sorry! That's the only spot I needed quotations. If I don't have them, Adobe tells me that I'm missing characters.
THANK YOU SO MUCH!!! I wish there was a way to give brownie points or something on here either than "Right Answer". You have helped me so much and deserve a lot of brownie points! Thank you!!
If Adobe is reading this, please give George Johnson a reward or something, please! He was very helpful and patient with me.
Copy link to clipboard
Copied
I'm glad you've got it working.
Here's another approach that may make it easier to set up. If you set the tooltip text to be the message you want displayed in the field, the code can then be:
// Custom format script for text field
if (!event.value) {
event.value = event.target.userName;
event.target.display = display.noPrint;
} else {
event.target.display = display.visible;
}
The "userName" property gives you the text you enter as the Tooltip text.
Copy link to clipboard
Copied
I know I am replying to a very old thread but this example was very helpful. I do have one question regarding a modification if possible.
I would like the label to show in the fill in field as the above script does however is it possible that when the pdf is saved after being filled in via reader those labels go away? (the original request is that they would remain) I see that they go away when the form is printed but I'd also like for them to go away if the user fills in the form and saves so that they can then email the pdf without those labels.
Thanks for any input as I wouldn't know how to modify the script even if this is possible.
Copy link to clipboard
Copied
You will need to more clearly define the condition under which the lables should remain, and should be gone.
I suggest you create a new post regarding this.
Copy link to clipboard
Copied
Thank you for the quick response, but I don't know how much more clear I can be.
I want the exact behavior as the above script provides except that I want the labels removed when the user saves the form from Reader the first time. (but not before the initial first save if possible). This is so the form can be emailed without the labels for any field in which no information was entered, as happens now when it is printed.
With the current script the user has to print the form and then scan it in order to send the pdf via email and not have blank fields show on the form without the label. Trying to avoid that extra step for the user.
Thanks.
Copy link to clipboard
Copied
You can use the file's Will Save event to remove that instructional text. However, you will then have to disable JavaScript on your computer when saving it, or it will happen right away and won't appear at all...
Copy link to clipboard
Copied
Thank you!! awesome