Previous | Next | (P-PDF) JavaScript
Topic: Postal Code
Conf: (P-PDF) JavaScript, Msg: 28848
From: Jub
Date: 10/20/2001 02:14 PM
Cindy,
A Regular Expression might work better for you.
In the FORMAT script try this...
event.value=util.printx(">A9A 9A9",event.value);
the '>' will force everything to upper case.
In the KEYSTROKE script try this...
if(event.willCommit && event.value)
{
/* i.e. only if something WAS entered
** and if the user is committing the value
** by tabbing, clicking away etc */
reCANZip = /[A-Za-z]\d[A-Za-z] *\d[A-Za-z]\d/;
/* this is the pattern...
** i.e. 'A+9+A+(0 or more spaces)+9+A+9' */
if(!reCANZip.test(event.value))
{
/* i.e. what the user entered does NOT
** match this pattern */
event.rc=false;
/* I always put the 'event.rc = false;'
** or 'event.value = "";' BEFORE the alert.
** Users can ESCAPE out of many of the alerts
** with Acrobat V4 (not sure if this is still
** true with V5) thus bypassing any following
** code ! */
app.a lert("Please enter Postal Code in the format A#A #A#");
/* You will need to take the space out of
** the 'a lert'...
** The forum filters out some key words
- like 'a lert' */
}
}
HTH,
Jub