How to modify a custom validation script

Hi to all,

I am on Acrobat Pro DC. I am preparing a fillable form and I would like to add and run a custom validation script for my country zip code.

I found the following script for US zip codes but I want to MODIFY the same to match 4 up to 5 digit zipcode only.

Please advise!
Thanks in advance

if(event.value == null || event.value == "") {
  event.rc = true;
else {
  if(event.value.match(/^(\d{5}(-\d{4})?)$/) == null) {
    app.alert('That was not valid for type: "US Postal Code".\r\nExample: NNNNN');
    event.rc = false;
    event.rc = true;

this is the regex that determines which zip codes are allowed or not, you will have to change it to do the think you need
this one allows for NNNNN or NNNNN-NNNN zip codes


Could you guide me where can I find regex completed forms preferably Admission Forms for Universities as an example in order to see the different regex validation scripts for each field by using them and learning how they’re working?


no, I have no idea where to find what you are asking for, it’s too narrow a thing to be if common knowledge. You may try googling, or learning regular expressions yourself

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.