title: error not display although old password and new password are same?
body: <p>I work on angular 7</p>
  
  <p>I compare between old password and new password </p>
  
  <p>if two both are same then error must display</p>
  
  <p>but in my case old password and new password are same  but error not display</p>
  
  <p>why error not display and How to solve this problem ?</p>
  
  <p>function CompareOldWithNew return false when both old and new are same value but error not display</p>
  
  <p>changepassword.ts</p>
  
  <pre><code> oldPassword = new FormControl('', [Validators.required, Validators.minLength(6), Validators.maxLength(10)]);
   newPass = new FormControl('', [Validators.required, Validators.minLength(6), Validators.maxLength(10),this.CompareOldWithNew("oldPassword")]);
    ngOnInit() {
      this.createFormResetPassword();
    }
    get c() { return this.ChangePasswordForm.controls; }
  
  CompareOldWithNew(field_name): ValidatorFn {
  
      return (control: AbstractControl): { [key: string]: any } =&gt; {
  
        const input = control.value;
        const isnotequalValues = control.root.value[field_name] != input;
        return  isnotequalValues ? null :{'old password must not match New': {isnotequalValues}} ;
  
      };
    }
    createFormResetPassword() {
      this.ChangePasswordForm = this.formBuilder.group({
   oldPassword: this.oldPassword,
        newPass: this.newPass
  })
  }
  onSubmit() {
  
      if (this.ChangePasswordForm.invalid) {
          return;
      }
  </code></pre>
  
  <p>changpaassword.html</p>
  
  <pre><code>&lt;div class="form-group"&gt;
    &lt;label &gt;OldPassword&lt;/label&gt;&lt;br&gt;
    &lt;input type="password" formControlName="oldPassword" class="textboxclass"   [ngClass]="{ 'is-invalid': submitted &amp;&amp; c.oldPassword.errors }" /&gt;
    &lt;div *ngIf="submitted &amp;&amp; c.oldPassword.errors" class="invalid-feedback"&gt;
        &lt;div *ngIf="c.oldPassword.errors.required"&gt;Password is required&lt;/div&gt;
        &lt;div *ngIf="c.oldPassword.errors.minlength"&gt;Password must be at least 6 characters&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
    &lt;label&gt;New Password&lt;/label&gt;&lt;br&gt;
    &lt;input type="password" formControlName="newPass" class="textboxclass"    [ngClass]="{ 'is-invalid': submitted &amp;&amp; c.newPass.errors }" /&gt;
    &lt;div *ngIf="submitted &amp;&amp; c.newPass.errors" class="invalid-feedback"&gt;
        &lt;div *ngIf="c.newPass.errors.required"&gt;Password is required&lt;/div&gt;
        &lt;div *ngIf="c.newPass.errors.minlength"&gt;Password must be at least 6 characters&lt;/div&gt;
        &lt;div *ngIf="c.newPass.errors.CompareOldWithNew"&gt;old password not match new &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>