Need a help on logical problem

I have a three textbox and there have a 100 fixed integer value and these value shared with three different field
suppose user put value on

Scenario-1
TEXT_BOX-1: - 50; (remaining value is 50) user cant put the greater than remaining value on TEXT_BOX-2 if user want to put 60 they cant put. they have to put 50 on TEXT_BOX-2.
TEXT_BOX-3 automatically filled with 0(zero)

Scenario-2
TEXT_BOX-1: - 40; (remaining value is 60) user cant put the greater than remaining value on TEXT_BOX-2 if user want to put 70 they cant put. but user can put less than remaining list 20 or they may be put 60 on TEXT_BOX-2.
if user put 20 at TEXT_BOX-2 reaming value automatically filled at if user put 20 at TEXT_BOX-2 reaming value automatically filled at TEXT_BOX-3 with 40

so on…
Please help me out.

Thanks in advance.

What I believe is, through ngmodel on those text boxes, you can achieve it.
Let’s try with these steps:

  1. text-box 1: get the length of the value entered with ngmodel(t1)
  2. text-box 2: get 2nd field values with ngmodel(t2)(let’s say t1 value is 50 and t2 value is 60 so the length will be failed in the condition check and you can through the error)
  3. If you compare both (t1.length+t2.length>100) don’t allow to enter more values(maybe disable the input field to enter values.).

Even though it may not be the complete soultion, might be helpful :slight_smile:

1 Like