How to validate PDF form?

醉酒当歌 提交于 2021-02-18 21:32:06

问题


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.


回答1:


You 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)




回答2:


You can do this without javascript as long as you are OK with the default error message.

  1. In Acrobat, while in edit mode, right click on the field
  2. On the Format tab, set the format to Number
  3. 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.



来源:https://stackoverflow.com/questions/1760154/how-to-validate-pdf-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!