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

Percentage field format

Avatar

Level 1

Hi,

I'm new to livecycle designer and I need your valuable help!

I'm making a form and I need to have some percentage fields, with data entered by filling the form.

These percentage fields should have format 000%. Ex. 005%, 035%, 100%

There should be an error message when the user tries to input a num greater than 100,

Also, I don't know if it could be done, to have a calculator script that summarizes all the input data and verify that the summary is aways 100. Ex. if field1 input=50, field2 input=30, field3 input=20, field4 input=0, field5 input=0, then it's ok!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

the percentage fields often confuses users, as it internally calcultes with floating numbers between 0 and 1.

For example: If a users enters 0.77 it will display 77%.

When you want users to enter the same values that should represent the percentage value, then you can use a numeric pattern with a string for the %.

Num{999.8'%'}

To calculate a summary of fields you can use FormCalc ind the percentage fields calculate event.

var summary = Sum(field1, field2, field3, field4, field5)

if (summary gt 100) then

     $host.messageBox("Summary cannot be more that 100%. Please check your data.")

     $ = 0

else

     $ = summary

endif

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi,

the percentage fields often confuses users, as it internally calcultes with floating numbers between 0 and 1.

For example: If a users enters 0.77 it will display 77%.

When you want users to enter the same values that should represent the percentage value, then you can use a numeric pattern with a string for the %.

Num{999.8'%'}

To calculate a summary of fields you can use FormCalc ind the percentage fields calculate event.

var summary = Sum(field1, field2, field3, field4, field5)

if (summary gt 100) then

     $host.messageBox("Summary cannot be more that 100%. Please check your data.")

     $ = 0

else

     $ = summary

endif