I have a writeable PDF form made in Acrobat Professional. I want to validate that a numerical entry is in a certain range [a,b]. If it is not, I want an alert to pop up with the message, "Please contact Larry at XXX-XXX-XXXX to get your form processed." Can someone write up a quick snippet of code that does this for a PDF? I know how to do it for a web form.
I have a writeable PDF form made in Acrobat Professional. I want to validate that a numerical entry is in a certain range [a,b]. If it is not, I want an alert to pop up with the message, "Please contact Larry at XXX-XXX-XXXX to get your form processed." Can someone write up a quick snippet of code that does this for a PDF? I know how to do it for a web form.
Share Improve this question edited Nov 21, 2009 at 0:52 user438293456 asked Nov 19, 2009 at 0:36 user438293456user438293456 5963 gold badges7 silver badges19 bronze badges 02 Answers
Reset to default 11You could do something like this:
if (event.value > 3 && event.value < 10) {
event.rc = false;
app.alert({
cMsg: "Please contact Larry at xxx to process your form.",
cTitle: "My Window Title",
nIcon: 0,
nType: 1
});
}
You can enter this validation script by editing the properties of a field. Go to "Validate Tab", click "Run custom validation script", then "Edit...". Type the code into the JavaScript Editor window, and then click "Ok" and "Close".
(source: skitch.com)
You can do this without javascript as long as you are OK with the default error message.
- In Acrobat, while in edit mode, right click on the field
- On the Format tab, set the format to
Number
- On the Validate tab, choose the second option and set a low and a high number for your range.
Now, when a user tries to supply an answer outside that range, an popup box will alert them to the error.