Validate sum of values (text boxes) against a 'master' total?


#1

Not sure if biting off more than I can chew here as never used Axure before and trying to test an improvement to an existing draft wireframe.
I have a text box, “MasterTotal”, that users can enter a value but I have three other text boxes; “Split1”, “Split2” and “Split3” that users can specify how that MasterTotal is split, but isnt mandatory.
I was trying to add a message box/text that pops up if the total of those three splits do not equal the MasterTotal input. I managed to kind of get it to work just for Split1 using IF and ELSE/IF when I thought I’d start simple (on TextChange of Split1 - if this doesnt equal that, show box, if it does equal, hide box, if cell"", also hide box etc) but I have realised I have no idea where or how to start configuring it that Split1 could equal the MasterTotal, or Split1+Split2 could or all three. It cant be Split2+Split3 or Split1+Split3 though just to be clear in case that would make a difference.
If anybody can even point me in the right direction, I would be grateful.


#2

I’d try to have the validation logic in one place – maybe even on the MasterTotal box. If you put it on the OnLostFocus event there, the validation will happen after the user finishes editing that value.

In concept, something like this:

OnLostFocus

  • If Split1 + Split2 + Split3 does not equal MasterTotal
    – [show message]
  • Else
    – [hide message]

Then, on each of the three split boxes, set it up so editing the split triggers the same validation on the MasterTotal widget:

OnLostFocus

  • Fire event OnLostFocus on MasterTotal

The great thing about doing it this way is that if you need to change your logic you can do it once, even though it’s triggered by multiple different user actions.

HTH
Jeff


#3

@Jeff_Harrison Apologies that I havent come back to you sooner for this but thank you very much! :slight_smile:


#4

No worries. You’re welcome!