Skip to main content
Participant
March 18, 2025
Question

Permanently add a form field to the custom category

So given the fact that I am in Canada, I would like to be able to add a permanent form field under the custom category - kinda like how the zip code one is already there. I already found a script for the postal code validation as seen here: 

event.value = event.value.toUpperCase();

if(event.value != "")

{

// validate Canadian postal code;

event.rc = /^(?!.*[DFIOQU])[A-VXY][0-9][A-Z] [0-9][A-Z][0-9]$/.test(event.value);

if(event.rc == false)

{

  app.alert("Please enter a correct Canadian Postal code", 1, 0);

  this.resetForm([event.target.name]);

}

}

(I found this on another post, created by a helpful member of the community)

With the display of the tooltip here, it sounds like you should be able to add your own custom scripts to this list, but I have no idea how to do it. Any help would be very appreciated! There's quite a few custom scripts that I would finally be able to add to this list. 

 

4 commentaires

PDF Automation Station
Community Expert
Community Expert
March 19, 2025

You could always create your own list triggered by a custom toolbar button that opens a dialog with a list of field names in the document, and dropdown of script names, that modifies the field based on your selection using the setAction method.

PDF Automation Station
Community Expert
Community Expert
March 19, 2025

I think that tooltip just means what is already in the list.  Here's how to use the arbitrary mask:

https://community.adobe.com/t5/acrobat-discussions/arbitrary-mask-question/m-p/14958392

Canadian postal code would be A9A9A9 but then you would need to leave the first line of your validation script: event.value=event.value.toUpperCase();

try67
Community Expert
Community Expert
March 18, 2025

I don't think that's possible, but would be happy to learn if it was!

Thom Parker
Community Expert
Community Expert
March 18, 2025

You would expect that there would be a preference or configuration file somewhere for adding items to this list of "Special" formatting options (similar to the preference file for the predefined redaction patterns), but there is not. At least not an obvious one.  I did a search on the registry for some of the names that appear in the list and found nothing.   So there doesn't appear to be a preference file or a registry item associated with these options.  Doesn't mean there isn't one, just that I don't know about it. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often