Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

How do I limit to the sum of a string of added numbers

Avatar

Former Community Member
I have a set of fields that the total should not exceed 100. The numbers will be entered by the user into numeric fields and I would like have it give an error to the user until the total is equal to 100. In context, it's a survey which the user will fill in percentages into the fields and the total percentage will not exceed 100.



FYI, I looked in the help menu and searched the forum for a similar solution. Ironically, the hardest part of this is explaining exactly what I need!



I'm using LiveCycle Designer 8



thanks!
2 Replies

Avatar

Former Community Member
This is what I have done in the past and it works for me.

Using JavaScript select Validate.



This is the code I used.



if (this.rawValue > 100)

{xfa.host.messageBox("The Total must be 100% or less.")};



This does not prevent them from entering the number but It tells them something is wrong.



Hope this helps

Carol

Avatar

Former Community Member
Thanks Carol, this helps a lot!

I probably can set each the sum fields as being required to equal 100 at runtime, unless anyone else comes forward with a better answer.