How to use variables to reduce redundant portions of references in validation script.
I'm trying setup a validation script that confirms that the user has entered a pre-approved number, and returns an app alert if they do not. I have a the script functioning properly but the array of pre-approved numbers is too large for acrobat (text it too large to be displayed in this dialog). I'm trying to use variables for the redundant portions of these numbers to reduce the overall script size.
Here's a sample of my script with a much smaller array of pre-approved numbers.
event.rc = true;
if (event.value != 1476542 && event.value != 1471222 && event.value != 1476895 && event.value != 1471248 && event.value != 1472347 && event.value != 1476246 && event.value != 1476254 && event.value != 1472833
)
{
app.alert("NOTE: You must enter a pre-approved number.", 3);
event.rc = false;
}
Notice how each number begins with 147. What I'm wondering is if I can use a variable to replace 147, thereby reducing the size of the script. I would also use variables to replace 148, 149, etc..
I tried this and it did properly recognize the pre-approved number, but it no longer triggered the app alert when a non-approved number was entered.
var x = 147
event.rc = true;
if (event.value != x6542 && event.value != x1222 && event.value != x6895 && event.value != x1248 && event.value != x2347 && event.value != x6246 && event.value != 1476254 && event.value != 1472833
)
{
app.alert("NOTE: You must enter a pre-approved number.", 3);
event.rc = false;
}
Thanks for your thoughts!
