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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How can we apply Display pattern for Text Field, to have Formatted Currency?

Avatar

Level 2

We have a Text Field in that we need to enter Numeric values more than 15 digits. we have to format that as a currency Field. (Value starting with $ and having comma separated, eg., $123,123,123.00). We tried using num{zzzzzzzzzzzzz9.zz} Pattern, but didnt give any luck. will there be any other way of providing pattern using some reserved Symbols ( * ? +). thanks in Advance
Sri

0 Replies

Avatar

Level 5

Hi Sri,

  Whats the reason to prefer Text field for you instead of Numeric field. As it is very easy to set the display pattern for numeric field and it has one of the display patterns that you are looking for.

  k.c

Avatar

Level 4

Hi K.C.

To answer your question. I think I know the problem they have:

When entering large numbers they might be wrongly overgiven if they are larger than 2^31.

There might be aftercommadigits added or (if you forbid that via pattern) the last digit might change.

So you tiptoe around that problem. You tell Livecycle that this is no number but a string. If it is treated as a string the value won't change. By using a pattern you can prohibit the user to write anything into it but a number and you can format it. (Though LC will dislike it and tell it is invalid, it works. In fact it works better than the textfieldpatterns I didn't get to work.)

PS.: Are you good with regular expressions? I still don't know how to delte the invalid values of my datefields...

Now to the real question:

I had the same problem once ;D

I'll check if I can make your patterns work there

...

Here is your pattern:

num{$zzz,zzz,zzz,zz9.99}

Check that your patternlanguage is set on USA too. And the number you enter includes a "." if you do aftercommadigits. It WILL NOT accept ",".

It gives a failure message out then. (You need to enter it in the "American style" because of the $. If you don't it might change to € when an European fills it out.)

If you enter something wrongly it won't be delted automatically like in a decimalfield. I'd suggest to check via script if there are "forbidden characters" in there. I am quite bad with regular expressions though, so I can't give you any good answer to this, how to achieve that. (Something I will have a look soon... because it is soooooo anoying to only see these little things and not be able to use them correclty.) Though if you need it, I am sure someone else will provide you with a good script.

Another little hint: Don't use these numbers in ANY calculations. They are strings right now.

I tried several ways to tiptoe around that problem, though the chance that the calculations get totally wrong (best case: the last digits like in decimalfields) are quite high.