Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Validation pattern for 4 digit number

Avatar

Avatar
Level 2
MichaelDeiss
Level 2

Likes

0 likes

Total Posts

33 posts

Correct Reply

0 solutions
View profile

Avatar
Level 2
MichaelDeiss
Level 2

Likes

0 likes

Total Posts

33 posts

Correct Reply

0 solutions
View profile
MichaelDeiss
Level 2

18-02-2009

Hi all,



very simple requirement but I find no solution: Only 4-digit numbers (e.g. 2344 or 2345) should be allowed in a numeric field.



I try to solve this with a validation pattern. My favorite pattern is "num{9999}". But this pattern validates also 1-, 2- or 3-digit numbers positive. Why? And what is the right pattern?



Thanks in advance,



Michael

Replies

Avatar

18-02-2009

Is 0003 allowed???

If yes you should simply put the pattern in all fields.

Avatar

Avatar
Level 2
MichaelDeiss
Level 2

Likes

0 likes

Total Posts

33 posts

Correct Reply

0 solutions
View profile

Avatar
Level 2
MichaelDeiss
Level 2

Likes

0 likes

Total Posts

33 posts

Correct Reply

0 solutions
View profile
MichaelDeiss
Level 2

18-02-2009

Dear Lisa,



thanks for the hint. Only values 1000-9999 are allowed.



Of course I can do that very easy by script validation, but I want to understand why the validation pattern don't work.



Thanks,



Michael

Avatar

18-02-2009

I'd make it per skript



VALIDATION - JAVA SCRIPT



if (this.rawValue > "999")

{

true;

} else {

false;

}



Limit it to 4 digits (like you've done already) and everything should work fine ^^

Edit: Probably you should make the field obligatory too (at least if it should be obligatory).



Hope that helped ^^



Lisa ^^

Avatar

Avatar
Affirm 3
Level 2
JohnBrinkman
Level 2

Likes

0 likes

Total Posts

20 posts

Correct Reply

3 solutions
Top badges earned
Affirm 3
Affirm 1
View profile

Avatar
Affirm 3
Level 2
JohnBrinkman
Level 2

Likes

0 likes

Total Posts

20 posts

Correct Reply

3 solutions
Top badges earned
Affirm 3
Affirm 1
View profile
JohnBrinkman
Level 2

25-02-2009

You could use a text picture instead of a numeric picture:

text{9999} will enforce that all 4 digits are supplied.

(Designer will give you a warning if it is a numeric field, but you can ignore the warning)



John Brinkman

http://blogs.adobe.com/formfeed