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

Text Fields/Numeric Fields Drop Leading Zero

levi.rogers
Registered: Nov 18 2008
Posts: 49
Answered

I have a field that will take input that can be anywhere from 5 numbers to 50 numbers.

However these are account numbers and sometimes start with a "0"(zero).

No matter how I seem to set the validation properties it always drops the leading zero.

This is difficult because not all account numbers have a leading zero.

Any help on this would be appreciated - should this be a script fix or is there a built in way to fix this.

My Product Information:
LiveCycle Designer, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi levi.rogers,

Don't use a number field, use a text field and make sure all operations are treated as text, not numbers.

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
levi.rogers
Registered: Nov 18 2008
Posts: 49
Well I changed that but I guess I'm unsure how to force it to read them as text not numbers.
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi levi.rogers,

Is this a straight entry field- the user will type the account number into the field- or does the number come from somewhere else? Do you need to have the validation pattern? If you make this a text entry field with no validation the leading zero should not get stripped.

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
formman
Registered: Jul 17 2008
Posts: 44
When I do a display pattern I just use "9"s for the pattern and set the length to a fixed number ( I use a text field for numbers too). So if you want a 10 digit number with leading zeros:

Display Pattern: 999999999

Rick Kuhlmann

Forms Developer/Designer
Tech-Pro, Inc.
Roseville, MN

hemant.reality
Registered: Jun 22 2010
Posts: 5
hi,

how to put restriction on users so that he can not enter alphabets in this text field.

my field for account number should either be numeric which can accept zero at the
beginning or text which only accepts numbers.

I tried following code in textfield's change event but it is still accepting alphabets

if(isNaN(xfa.event.change)) xfa.event.change = "";
if(isNaN(xfa.event.prevText)) xfa.event.change = "";


regards,
hemant.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
[color=#333333]@hemant[/color]
[color=#333333][/color]
[color=#333333]Use a numeric field to allow numeric inputs only.[/color]
[color=#333333][/color]
[color=#333333]To display the numbers with leading zeros use a pattern such as: num{99999}.[/color]

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

nalakahe
Registered: Jul 17 2011
Posts: 11
Dear Acrobat Form Experts,

I have the same problem as above at acrobat forms.

Dear Acrobat Form Expert,

In Acrobat Form i required, fields to insert account numbers like "000150125" which start with "0"(zero).
without making the field text, how I’m going to appear as 000150125.

Also, alphabets should be restricted for users.

Regards
Nalaka

NalakaHE

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
After you add the "Text" form field to the template:
Select the form field
Select the "Object" tab.

On the "Field" tab:
Field Format: text{999999999}
Display Pattern:text{999999999}

On the "Value" tab:
Validation Pattern: text{999999999}

The above will detect non-numeric values entered into the field upon exit. If you want to trap errors as typed, then you will need to use some script coding. There are also options for a custom entry error message.

A "Text" field needs to be used because numeric fields are stored in a special form called IEEE754 64-bit binary values and this data format suppresses leading zeros. More information about the XFA FormCalc Specification will explain more about the formats and literals.

George Kaiser

nalakahe
Registered: Jul 17 2011
Posts: 11
Dear Kaiser,
Pl explain me little further. I am using Adobe Acrobat Pro.
And i couldn't find object tab.
Regards
Nalaka

NalakaHE

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You have posted in the LiveCycle Designer forum. The instructions that have been given are for LiveCycle Designer. LiveCycle Designer is part of the Acrobat suite but the application creates XML forms and this is significantly different than Acrobat at the design level.

If you are using Acrobat then you use a text field and in JavaScript access the value of a field using the 'valueAsString' property.

George Kaiser