Copy link to clipboard
Copied
I have a dynamic PDF Timesheet used in the field. It has a cost code field we would like to set limitations on to reduce mistakes. The single field needs to accept two styles of entry because our accounting software requires these specific formats:
9-99-999 or 99-99-999
(I wrote these in an Arbitrary Mask format as that is what I started with. So anywhere you see a "9" that can accept any number from 0-9.)
It's important to know the first value cannot simply be entered with just a 0 value in front of a single digit as the accounting system won't accept it. This is why there must be two options for entry in this specific cost code field. (ex. 1-01-120 cannot read 01-01-120 or it won't work)
Additionally, whatever I create has to run on mobile devices (iPhone/iPad specifically, and maybe even Android) which means Javascript's could be problematic if I need to write this using scripts. A single Arbitrary Mask option works on mobile devices as I've tested it thoroughly but I'm unable to find a way to set it to accept two styles of entry.
Additionally, I thought maybe I could use a script that would simply pop-up an error and highlight it red if they didn't use one of these formats but I'm struggling with writing it correctly and also I still have the issue of it possibly not working right on mobile devices. All our iPad are iPad Air 2 or newer versions. They're all running the latest iOS with the latest PDF Expert. (Looking forward to PDF Expert 7's release)
So if anyone could help with things I could try that would be amazing!!!
Copy link to clipboard
Copied
If you want to allow more than one type of value then you have to use a script, which as you mentioned, might not work on mobile devices, so you'll need to test it carefully.
The way to do it is with a regular expression, like this:
if (event.value) {
event.rc = false;
if (/^\d{2}-\d{2}-\d{3}$/.test(event.value)) {
if (/^0/.test(event.value)==false) {
event.rc = true;
}
} else if (/^\d{1}-\d{2}-\d{3}$/.test(event.value)) {
event.rc = true;
}
if (event.rc==false) {
app.alert("Invalid value.");
}
}
Copy link to clipboard
Copied
The mask can be made even more restrictive by using JavaScript's RegExp object.