Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Pattern Display Question

Avatar

Level 3

I'm guessing this has to do with how it is displayed under the patterns.  I'm looking for a way when the user enters for example $5,000,000.00 it displays the shorthand version of $5M instead.  Is this possible?? Any help on this is much appreciated. Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I don't think that there is an automatic/easy way to do this. You probably could do it using script in the exit event. It would have to examine the value, convert it to a string and for each group of three "0", assign a letter.

EG if it finds three zeros, strip them out of the string and add a "K". If there are six zeros, strip them out and add an M.

The trouble is you are taking a Number (which you can do further calculations with) and making it a String (which you can't really work with afterwards).

Also I think that the script will be a bit cumbersome, in dealing with all of the possible inputs. For example, $5,125,030.15.

Niall

View solution in original post

4 Replies

Avatar

Level 3

Okay this works but when I input the numbers it just shows up with a M on the end.  For example, I'm typing in $5,000,000.00 and it shows up at $5,000,000.00M when I want it to do $5M.  Is there a script to do this maybe?  I forgot to mention...I guess what I'm really looking for is if someone types in $5.00 it displays $5.00 but if someone puts in $5.500,000.00 is displays $5.5M and so on and so on with billions also.

Avatar

Correct answer by
Level 10

Hi,

I don't think that there is an automatic/easy way to do this. You probably could do it using script in the exit event. It would have to examine the value, convert it to a string and for each group of three "0", assign a letter.

EG if it finds three zeros, strip them out of the string and add a "K". If there are six zeros, strip them out and add an M.

The trouble is you are taking a Number (which you can do further calculations with) and making it a String (which you can't really work with afterwards).

Also I think that the script will be a bit cumbersome, in dealing with all of the possible inputs. For example, $5,125,030.15.

Niall

Avatar

Level 3

Okay thank you...I was just wondering if there is an easy way to do it but this let's me know there is not.  Thank you!