These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

JS to validate input

rajayc
Registered: Jul 8 2009
Posts: 2

I'm very new to javascript and i'm currently struggling with tryin to come up with code for a text field i have on a pdf form.
What im trying to do is make it so that only certain characters can be entered into that field. For example it must be in the A9999 format (capital letter, followed by 4 numbers). If anything other than that format is entered an error message should pop up and the field is reset to null.
As i said i am brand new to Javascript and it is tough as i am use to visual basic programing. Any help would be greatly appreciated.
Thanks

Rajay

My Product Information:
Acrobat Pro 8.0, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
The easiest way is to select the 'Special' formatt option on the 'Format' tab and enter 'A9999' for the 'Arbitrary Mask' and then using the following code for the vaildation script:
event.value = event.value.toUpperCase();
A more elegant and complex solution could be done using the RegExp object and writing custom scripts for the keystroke, format and validation.

George Kaiser