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

How to determine if a text field is numeric

sz4zkk
Registered: May 23 2007
Posts: 26

I am using Lifecycle Designer 8.0. Using script how can a validate that a text field contains numeric characters? I can't seem to find a command to perform the check.

My Product Information:
Acrobat Pro 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are 3 ways.

1. (Easy) - Use a Numeric field. Guaranteed numeric entry

2. (Medium) - Set a data, display, edit, and/or validation pattern on the Object Panel for the field. Any or all of these can be used to set some level of numeric compliance

3. (Difficult) - Write a validation and/or change script for the field. "change" event is called for keystrokes so you can use it to enforce data entry restrictions.

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

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I think I misunderstood your question. I think you're looking to find the numeric parts of a Alpha/Numeric entry.

You do this with a script. This is a Core JavaScript thing, not an Acrobat or LiveCycle thing. So it's not suprising that you couldn't find it in the Adobe Documentation. It's very simple, use a Regular Expression.

Suppose that you have a field named "MyAlphaNum". A script in another field might look for a numeric part of MyAlphaNum's value like this:

// This tests for the presense of digits
var bHasNum = /\d/.test(MyAlphaNum.rawValue);

// This tests for an integer or floating Pont number
var bHasFloat = /\d+(\.\d+)?/.test(MyAlphaNum.rawValue);

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