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?

Thanks.
asked Apr 12, 2016 by WTW_cal Bronze (1,375 points)

1 Answer

+1 vote
 
Best answer
Via custom JavaScript verification:

$(document).ready(function(){
    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. (83,900 points)
selected Apr 14, 2016 by WTW_cal
Remaining constant sum baked right into the question (visually)
...