Copy link to clipboard
Copied
Urgent... Please help!
Good day all. Please i am in serious need of your help and this is very urgent. I need to get this out in 5 hours to my client.
So, there is this fillable pdf form i created for my client and the client is requesting that i create specific fields to ONLY accept specific correct answers. Also, if the answers are wrong, the field should retrun back an error by maybe highlighting red error background or anything that would show its an error. Besides, he doesnt want a drop down menu or something.
For example: If the response to a text field is supposed to be "HOME" , if the user types in HOUSE, the form should return an error until the words HOME has been typed in. This is just a random scenario/example i just made.
Please can anybody help me out with a java script that can help me achieve this for my client. I really do not want to lose this job.
Thank you in advance.
Copy link to clipboard
Copied
You can use something like this as the field's custom Validation script:
if (event.value && event.value!="HOME") {
event.target.textColor = color.red;
app.alert("INCORRECT ANSWER!");
} else event.target.textColor = color.black;
Copy link to clipboard
Copied
Copy-paste the field in the attached PDF.
Beware that JavaScript is case sensitive, so "HOME" is not "Home" or "home".
Copy link to clipboard
Copied
You can use something like this as the field's custom Validation script:
if (event.value && event.value!="HOME") {
event.target.textColor = color.red;
app.alert("INCORRECT ANSWER!");
} else event.target.textColor = color.black;
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Remove " at the begin and end.
Copy link to clipboard
Copied
Remove the quotes you added at the beginning and at the end of the script.
Copy link to clipboard
Copied
Thanks. It accepted the javascript now. But it seem not to respond to the instruction. It still does not respond to the javascript. Maybe i am entering it in the wrong place.
I selected the text field and clicked on the properties. Then i clicked on ACTION menu.
Question:
1. What trigger do i select in this instance. I have tried almost all the options in there.
2. What action do i select? I have tried RUN A JAVASCRIPT
Like i said before, i have successfully entered the script and it shows Run A Javascript like in the screenshot below. But even if i type my name MARK in the text field, it accepts it and saves instead of rejecting it as an error. I want the word HOME only to be accepted. It should reject all other words and pop up as INCORRECT ANSWER as in the script.
Copy link to clipboard
Copied
Add the script at Validate.
Copy link to clipboard
Copied
You should read this, it's very useful: https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#document-event-...
Copy link to clipboard
Copied
Thanks for the resource. But, it even got me lost. Am just a newbie to this process.
Copy link to clipboard
Copied
Just use the code I provided, and follow the instructions carefully. Don't add, delete or improvise anything, and you'll see that it works fine.
Copy link to clipboard
Copied
Yes i did. But the field doesn't even respond or run the javascript. I am thinking i entered the code in the wrong place, i really dont know.
Copy link to clipboard
Copied
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more