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

Force only 5 integers

Ciupaz
Registered: Jan 29 2009
Posts: 75

Hi all,
first of all, I'm new to Adobe Forms, and I'm making experience right now.
The problem is:
I have one field that must contains only 5 numbers, not less not more, and I'd like the user cannot insert alphabetical digit.
How can I set a pattern, or a JavaScript script to solve this problem?

Thanks in advance.

Luigi

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You don't need JS for this.
Just create a numeric field and set the maximum number of digits to the value you want in it's object tab.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Ciupaz
Registered: Jan 29 2009
Posts: 75
radzmar wrote:
You don't need JS for this.
Just create a numeric field and set the maximum number of digits to the value you want in it's object tab.
Hi Radzmar, thanks for response.
I've setted NumericField for my field, but I'v not found (in the Object palette) where to fix only 5 integers.
Where I can force this rule?

Luigi
Ciupaz
Registered: Jan 29 2009
Posts: 75
Another problem, when the user insert the number:

12345

it appears

12,345

which is not correct (should be 12345; it not a currency value).

Luigi
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The object tab shows 3 sub tabs when you select your nummeric field. Cell, Value, Binding (translated from german, namings may be different!)
Under "cell" you can find 2 checkboxes, one is for character limitation. Click it and type in your maximum of characters, the users can type in.
The other problem you can fix under "binding" where you have to change the format of your numbers.
It generally set to flowting point numbers. Change it to Integer.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Ciupaz
Registered: Jan 29 2009
Posts: 75
Under my Object palette I have 3 tab: Field - Value - Binding

In the Field tab I setted "Comb of " 5 "charactes", but now it appears with bold cell separator, that is not want I'd like.

For the comma separator, it's already "Data format" = integer, in Binding tab, but appears with commas all the same.

Luigi
Ciupaz
Registered: Jan 29 2009
Posts: 75
Any news about this problem?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Did you set a pattern for displaying of the numeric field?
I used this num{zzzzzzzz9}, so there is no comma separator then.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Ciupaz
Registered: Jan 29 2009
Posts: 75
I've set num{zzzzzzzz9} in Validation Pattern under Value tab, but does not work properly, because the use can insert less or more of 5 integers.
I'd like to prevent users to insert less or more of 5 digits.
cyprd
Registered: Oct 21 2008
Posts: 49
Hi Ciupaz,

you can put formcalc script in the validation event of that field. This way if user enters less or more than 5 digits, the field gets cleared and cursor returns to the field. I am surprised that pattern num{99999} didn't work for you. It should "upgrade" the shorter number to 5 digits, but I am not sure, what it does with longer one.

Well here is the script that will work for you:


if ($.rawValue>9999) then
if ($.rawValue<100000)then
1
else
if($<>null) then
0;
$host.messageBox("Please enter number between 10000..99999")
$.rawValue=""
$host.setFocus("NumericField1")
endif
endif
else
if($<>null) then
0
$host.messageBox("Please enter number between 10000..99999")
$.rawValue=""
$host.setFocus("NumericField1")
endif
endif

I did code it some time ago, but it should work well :-)

J.

Adobe LiveCycle ES 8.2.1 (JBoss & Win)

Ciupaz
Registered: Jan 29 2009
Posts: 75
Perfect cyprd, this works fine.

Luigi
Ciupaz
Registered: Jan 29 2009
Posts: 75
Hi cyprd,
a little problem.
If the user insert 01234 - that is a valid value - the script says it's not valid.
How can I solve?

Thanks.

Luigi
cyprd
Registered: Oct 21 2008
Posts: 49
Hi Luigi,

It depends, if you require the leading zero in your application. If so, than you probably have to use some more validation. Like changing the field to text field, make sure that it is limited to 5 characters and than do conditions to check if the length is 5 and if it contains only numbers

Jan

Adobe LiveCycle ES 8.2.1 (JBoss & Win)

Ciupaz
Registered: Jan 29 2009
Posts: 75
Have you an example Jan?
The users can insert only 5 integers (not letters, not less or more of 5 integers).
And if the user insert 01234 the form has not to change it in 1234.

Luigi