Copy link to clipboard
Copied
I have the prompt text figured out using this script taken from this forum: Is there a way to add instructional text to my text field that will disappear when clicked? (PDF For...
// Custom Format script for text field
if (!event.value) {
event.value = "Instructional text goes here";
event.target.display = display.noPrint;
} else {
event.target.display = display.visible;
}
Is their a way to change the prompt text's size and make it different from the type size I have set for them to fill out in the form. I want the type size of the prompt to be smaller than what size they use to fill it out.
Why yes there is, and your code is already setup for adding it. The "display" is a property of the text field object, and it is being set one way for the help text, and another way when the user enters the text. The text size is also a property of the text field object and it can be set in the same way.
// Custom Format script for text field
if (!event.value) {
event.value = "Instructional text goes here";
event.target.display = display.noPrint;
event.target.textSize = 12;
} else {
event.target.displ
...Copy link to clipboard
Copied
Why yes there is, and your code is already setup for adding it. The "display" is a property of the text field object, and it is being set one way for the help text, and another way when the user enters the text. The text size is also a property of the text field object and it can be set in the same way.
// Custom Format script for text field
if (!event.value) {
event.value = "Instructional text goes here";
event.target.display = display.noPrint;
event.target.textSize = 12;
} else {
event.target.display = display.visible;
event.target.textSize = 9;
}
You could also set the size on the keystroke event, or the OnFocus event, to capture the moment the user starts typing in the field.
Copy link to clipboard
Copied
Hey Thom,
You could also set the size on the keystroke event, or the OnFocus event, to capture the moment the user starts typing in the field. How would I do that? I'm very new to this.
Copy link to clipboard
Copied
Add this to the custom Keystroke script on the field
if(!event.willCommit)
event.target.textSize = 9;
It sets the text size to 9 at the moment the user types the first character in the field
Copy link to clipboard
Copied
Thank you so much Thom! Do you have any books or websites you could recommend where I could learn more creating advanced forms? It was very hard to search for my answer. Thanks again for your help.
Copy link to clipboard
Copied
Why Yes I do pdfscripting.com
Copy link to clipboard
Copied
How do I add this custom action to the text field. nowhere in the actions box, under text field properties is a place to add something custom. It just offers a set list of items. Please advise.
Copy link to clipboard
Copied
You must use a text field, not a drop-down.
Copy link to clipboard
Copied
? It's already a text field. I'm trying to make it have instructional text that disappears once the user types in content, much like the title of this conversation, but i have no way of knowing how to apply the custom script to the text field thru > Properties > action ... ?
Apparentlt there's another way. Please advise.
Copy link to clipboard
Copied
Some folks say to use the Text Field Properties>Actions tab, but the Format tab is the one where you can apply a Custom script. Why is that so hidden in all the conversations? Vague? It certinly wasn't as simple as it should have been.
Thanks for your time though.
Copy link to clipboard
Copied
The Actions tab on the field properties dialog provides a list of built-in actions for the mouse/cursor events. One of these "Actions" is "Run a JavaScript". So you can easily add a custom script to one of these events.
However, if you will re-read the original qestion and answer, you'll see the provided code is specifically for a Custom Formatting Script, and the follow on comments provide alternate code for using a Custom Keystroke Script. A later comment even shows a screen shot of the field properties dialog and the location where the code is entered in the Format Tab. There is no place in this thread where anyone suggest entering the code on the Actions tab.
Copy link to clipboard
Copied
Maybe I misunderstood what you meant by "It just offers a set list of items".
Copy link to clipboard
Copied
Using this script. Is there a way to add multi-line instructions eg:
event.value = "Instruction example one"
next line "Instruction example two"
Thank you
Copy link to clipboard
Copied
Yes, in field properties under 'Options' tab, select 'Multiline' and use '\n' for new line in text something like this:
event.value = "Instructional text goes here\nText for second line goes here\nText for third line...etc";
Copy link to clipboard
Copied
Thank you! that worked perfectly
Copy link to clipboard
Copied
Hello, is there a way to change the instructional text? I would like to make it a lighter color or red.
Copy link to clipboard
Copied
I have tried this so many times and it won't work for me. I'm wondering if it's because I'm using the newest version, but I can't find any more recent answers on this topic.
Copy link to clipboard
Copied
The code works perfectly in all versions of Acrobat/Reader. But it only works when the PDF is viewed in Adobe Acrobat/Reader, or another compliant viewer that implements the JS model, i.e., it won't work in a browser or mobile PDF viewer.
Can you post an example of a PDF where you have used the script and it didn't work?
Copy link to clipboard
Copied
Thanks. Now how do I apply this java script to all my text fields in one step? I want to avoid having to go to all my 300 comment boxes, open them and insert instructional text to my text field .
Copy link to clipboard
Copied
You want the same instructions for all text fields?
Copy link to clipboard
Copied
Yes for all text fields
I am using the script below to add instructional text to my text field that will disappear when clicked. But the script is only valid for one box.
Now how do I apply this java script to all my text fields in one step? I want to avoid having to go to all my 300 comment boxes, open them and insert instructional text to my text field.
if (!event.value) {
event.value = "Instructional text goes here";
event.target.display = display.noPrint;
} else {
event.target.display = display.visible;
}
Copy link to clipboard
Copied
Note: Comment boxes are not form fields.
Copy link to clipboard
Copied
I don't think I used "form fields" in my question. I wrote "text field"
Are you saying I cannot do it? Or I can?
I want the same instructions for all text fields.
Copy link to clipboard
Copied
form text fields or comment text fields?
Copy link to clipboard
Copied
It is a text field where users can insert their comments.