title: how to solve logical error in if conditions in angular
body: <p>I have a very simple logic and I have written conditions on that, I find the logic perfectly fine but it is always giving false results.
  I have three fields immediate limit, hold limit and LDC. So the condition is when immediate limit and hold one limit are numeric values sum of them should be less than LDC and individual values of each limits should also be less than LDC.(When the limit values are not numeric they return a negative no.)</p>
  <p>Here's my code:</p>
  <pre><code>immediateLimitError: boolean = false;
  hold1LimitError: boolean = false;
  ldcLimitError: boolean = false;
  sumOflimitVal: any;
  changedLdc!: any;
  changedImmediateLimit!: any;
  changedHold1Limit!: any;
  
  private instantiateValidation(row: any) {
          this.newHoldSchedule = this.formBuilder.group({
              immediatereleaseForm: [(row.hold1ReleaseAmt != null ? row.hold1ReleaseAmt : ' '), Validators.required],
              ldcForm: [(row.ldcAmt != null ? row.ldcAmt : ' ')],
              holdOneLimitForm: [(row.hold2ReleaseAmt != null ? row.hold2ReleaseAmt : ' '), Validators.required]
          });
          this.changedImmediateLimit = row.hold1ReleaseAmt;
          this.changedHold1Limit = row.hold2ReleaseAmt;
          this.changedLdc = row.ldcAmt;
  
          this.newHoldSchedule.get('immediatereleaseForm')!.valueChanges.subscribe(val =&gt; {
              this.changedImmediateLimit = val;
              if(this.changedHold1Limit &gt;= 0 || val &gt;= 0 ){
                  if((val + this.changedHold1Limit) &gt; this.changedLdc || 
                      val &gt; this.changedLdc || 
                      this.changedHold1Limit &gt; this.changedLdc){
                          this.immediateLimitError = true;
                  }
                  else{
                      this.immediateLimitError = false;
  
                  }
              }
            });
            this.newHoldSchedule.get('holdOneLimitForm')!.valueChanges.subscribe(val =&gt; {
                this.changedHold1Limit = val;
                if(this.changedImmediateLimit &gt;= 0 || val &gt;= 0 ){
                  if((val + this.changedImmediateLimit) &gt; this.changedLdc || 
                      val &gt; this.changedLdc || 
                      this.changedImmediateLimit &gt; this.changedLdc){
                      this.hold1LimitError = true;
                  }
                  else{
                      this.hold1LimitError = false;
                  }
                }
              });
              this.newHoldSchedule.get('ldcForm')!.valueChanges.subscribe(val =&gt; {
                  this.changedLdc = val;
                if(this.changedImmediateLimit &gt;= 0 || this.changedHold1Limit &gt;= 0 ){
                  if(val &lt; (this.changedImmediateLimit + this.changedHold1Limit) || 
                      this.changedHold1Limit &gt; val || 
                      this.changedImmediateLimit &gt; val){
                      this.ldcLimitError = true;
                  }
                  else{
                      this.ldcLimitError = false;
                  }
                }
              });
  
  }
  
  if(this.immediateLimitError || this.hold1LimitError || this.ldcLimitError){
                      this.displayError('The sum of Immediate Release limit and Hold 1 Limit exceeds LDC');
                      event.preventDefault();
                  }
  </code></pre>
  <p>This code works on some values and some values it is giving false results. I tried debugging and changing the conditions but it doesn't work how I want it to work. Any help would be appreciated. thanks</p>