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

Looking for a way to validate that a TextField 's data is numeric.

sz4zkk
Registered: May 23 2007
Posts: 26

I have a TextField defined on my master page. I need to validate that the data entered is numeric. I know it should be a simple thing to check for, but I cannot find a method to check this. Can anyone help me out.

Thanks in advance,
sz4zkk

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
The easiest way is to set the field's format property to numeric. The method to do this depends on whether you are using an Acrobat form or a Live Cycle Designer form.

George Kaiser

sz4zkk
Registered: May 23 2007
Posts: 26
I am using Life Cycle Designer. I am using a validation pattern of 999999999 and a display pattern of 999-99-9999 (SSN). If I set the field to numeric, then when I type in less than 9 digiits (ex: 1234), I get 000-00-1234. I also don't have any control over how many digits are typed in.

With a text field I can control the length. If I type letters in, the validation pattern kicks in and displays an error. But, I am trying to validate the data prior to printing. If garbage is typed in they can still print the form. I need to validate that what they was type in is numeric. I'm just not sure how to perform the validation.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Even though SSN is an acronym with the word "Number" in it, in for processing it is text field for computer processing. After checking some basic XML guides, the pattern for the SSN is:

[0-9][0-9][0-9][-][0-9][0-9][-][0-9][0-9][0-9][0-9]

or

[0-9]{3}[-][0-9]{2}[-][0-9]{4}

Just like RegExp notation.

Or for the display pattern:

999-99-9999


Here is an Adobe tutorial:

http://www.adobe.com/devnet/livecycle/articles/lc_designer_validation_tutorial.pdf

Samples for Version 6.0

http://partners.adobe.com/public/developer/xml/topic_samples1.php

George Kaiser

sz4zkk
Registered: May 23 2007
Posts: 26
I tried your suggestion, but Life Cycle designer said it was an invalid format. I tried [0-9]{3}[-][0-9]{2}[-][0-9]{4} and [0-9][0-9][0-9][-][0-9][0-9][-][0-9][0-9][0-9][0-9], but it didn't like either format.

My field validation is working when I leave the field, but I have a print button on my form. Whether the data on the form is filled in correctly or not, the form will print. I am doing some field validation on the print button and preventing them from printing if the fields do not validate correctly. Somebody can put ABC-DE-FGHI in for the SSN and when they tab off the field the validation on the field is producing the correct error message. But, if they ignore that and hit Print, the form will still print.

I just need a way to run a numeric check on the field during the printing validation. Is there a way to do a numeric check on a text field?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
I finally got to a machine with LiveCycle Designer. If you go to the "Custom" tab of the object library, you will find a field type called "US Social Security Number" select this item and you will get a field labeled "SSN" that is a text field with the "Display" string of "999-99-9999". You can also do the same with just a text field with the display set to the same string.

George Kaiser