How to control and check number input in a household entry (Validation during capturing)

1. What is the issue? Please be detailed.
I want to control entry of a household size followed by different age groups of that household size. A series of validations to match the total household size with age groups
Total_Control (1).xlsx (12.1 KB)

2. What steps can we take to reproduce this issue?
Look at my code and advise

3. What have you tried to fix the issue?
Adding constraints to control while capturing is on going

4. Upload any forms or screenshots you can share publicly below.

Hi @bkgwadi

Your requirements are not clear, please share your use case. Looking at your form my understanding is that you want the total number of males and females to match the totals for the various age groups. If my assumption is correct, a way of achieving what you want is to have 2 notes fields. First note field for the TotalPeople, then Second note field summing the values of the Age group fields.

The constraints in your current form, do not seem valid for what you want to achieve.