Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Constant Sum error message math

I have a client who is asking if we can have the error message show the remaining difference, basically:

[%ErrTotal()%] <minus> [%ErrCurSum()%]

Can the error messages interact with math operators?

asked Apr 12, 2016 by Colin Linerode Bronze (1,625 points)

1 Answer

+1 vote
Best answer
Via custom JavaScript verification:

    var total = 100;
    var sum = $('#ConstantSumQ_div .question_body tbody tbody > tr:last-child input').val();
    var remaining = total - sum;
    if (remaining > 0)
        strErrorMessage = 'You need ' + remaining + ' more.';

You will need to set the custom JavaScript verification to run before the system JavaScript verification, rather than after.
answered Apr 12, 2016 by Zachary Platinum Sawtooth Software, Inc. (205,575 points)
selected Apr 14, 2016 by Colin Linerode