1
0
-1

I want to validate a table of percentages which must add up to 100.

If I put my validation rule on the last option, it does not trigger if the applicant chooses a zero-value (empty).

If I put my validation rule on all the options, it triggers every time I change a value, and fails validation while the applicant is filling.

How do I display a warning only at the end, but prohibit navigation on page change?

 

    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      Wrap all your decimal fields in a block and put the validation rule on the block. Error message will appear at bottom of block, below all fields. I tested with three fields and the following validation rule on the block, seems to meet your requirements:

       

      +data.percentA + +data.percentB + +data.percentC === 100 || "These must add up to be 100"
      1. Sacha Trube

        Tim, My failure tests work fine, but this won't pass validation under any circumstance. Sorry, have to vote down.

      2. Sacha Trube

        Also, double plusses seem to cause syntax errors in the linter.

      3. Sacha Trube

        Seems the double plusses are mandatory to make this script function. Ignored the linter warning, and it works fine.

      CommentAdd your comment...