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

Script to check if a text field has 19 characters ?

Flash2009
Registered: Sep 7 2009
Posts: 11
Answered

Hello,

I'm having the following little problem and i'm hoping that anyone here can help me solve it.

I made an PDF form with several text fields which all have to be checked if the (numeric)
value entered is exactly 19 characters long.

Each of these text field has the following mask "9 9 9 9 9 9 9 9 9 9".
(So 10 positions for the entered numbers and 9 space characters.)
When a number is entered in these text fields the space is also automatically added to the entry.

Now what i would like to do is to check if a (numeric) value entered in these text field has the correct
length of 19 characters.

If the length is NOT 19 characters an error message has to appear.

If the length of the value entered is exactly 19 characters or empty (0 characters) no error
message has to appear.

Is there an easy way to do this ?

Maybe a (JavaScript) validation script could do this, or maybe this can be done with a standard
built in feature in Acrobat Professional ?

Who can help me solve this problem ?

Thanks :-)

Flash

My Product Information:
Acrobat Pro 8.1.3, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Use a validation script.

Here's a simple example:

event.rc = event.value && event.value.length==19;You could get fancier with a Regular expression and also test the input format

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script