Constraint does not work

I’m stuck performing a task for my form design. indeed, I would like to make this condition.
If the total sum of people in the household (total adlutes + total children) is greater than that declared (value entered) by the respondent, then an error message is displayed and does not allow me to go to the next step . In summary, the total sum of people in the household (total adlutes + total children) which is a calculated value, must be absolutely equal to the household size declared verbally by the respondent.
Need your help urgently

2- If the calculated value corresponds to that declared (household size) then the bottom of the cell turns green highlighted (bottom of the input field)

On the other hand, if the value does not correspond, this will mean that there is an inconsistency and when the error message is displayed, the background of the cell where the result must be displayed is highlighted in red.2021_01_05_16_29_05_essai_contrainte_KoboToolbox aasuoDVoPL2KNTKP3qmoio.xlsx (8.9 KB)

Thank you

You can have a validation constraint in the input for “how many women”.
.=${household_size}-${num_of_men}
Please see the attached excel file.

aP6DeS5pR82bwL97rzEn8q (1).xlsx (9.3 KB)

1 Like