Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Getting field length and splitting the value

Avatar

Level 3

I don't now how to get the field length of a decimal field (round numbers)

And how to split the numbers to perform a calculation on them

Like:

345 = lenght 5

value1*9 = 27

value2*2 = 8

value3*4 = 20

Anyone who can help me?

1 Reply

Avatar

Level 10

Hi,

Try .rawValue.toFixed().length you might have to check that they have entered a value first, that is rawValue !== null.

Have a look at https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number and https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Math

To get the fractional part of the number try;

rawValue - Math.floor(rawValue)

Good luck

Bruce