Compare password in angular reactive forms [closed]












1















For compare password, I am using rxwebvalidators and it is working fine when I enter the value in password field after that confirmPassword field. If the confirmPassword field value is incorrect while entering the text then the FormControl become invalid.



But the problem is if the both controls have same value and I change the value in password field then confirmPassword field will not be invalid. But in actual case It must be invalid.



I tried in my local project and also create a small replica on stackblitz for you reference : https://stackblitz.com/edit/angular-nriznm?file=src%2Fapp%2Fapp.component.ts



I do the following:



    this.userForm = this.formBuilder.group({
password:[''],
confirmPassword:['',RxwebValidators.compare({fieldName:'password'})]
})




Below is my html code :



<form [formGroup]="userForm">
password <input type="text" formControlName="password"/><br/>
compare password <input type="text" formControlName="confirmPassword"/>
{{userForm.controls.confirmPassword.errors | json}}
</form>




I have spend more than hour to identify the cause, but no success. Please help where I am doing wrong. It's working on rxweb.io site : https://rxweb.io/form-validations/compare/validators#basiccomparevalidation










share|improve this question













closed as off-topic by Vega, Nkosi, Cœur, AdrianHHH, Makyen Jan 1 at 15:58


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Vega, Nkosi, Cœur, AdrianHHH

If this question can be reworded to fit the rules in the help center, please edit the question.





















    1















    For compare password, I am using rxwebvalidators and it is working fine when I enter the value in password field after that confirmPassword field. If the confirmPassword field value is incorrect while entering the text then the FormControl become invalid.



    But the problem is if the both controls have same value and I change the value in password field then confirmPassword field will not be invalid. But in actual case It must be invalid.



    I tried in my local project and also create a small replica on stackblitz for you reference : https://stackblitz.com/edit/angular-nriznm?file=src%2Fapp%2Fapp.component.ts



    I do the following:



        this.userForm = this.formBuilder.group({
    password:[''],
    confirmPassword:['',RxwebValidators.compare({fieldName:'password'})]
    })




    Below is my html code :



    <form [formGroup]="userForm">
    password <input type="text" formControlName="password"/><br/>
    compare password <input type="text" formControlName="confirmPassword"/>
    {{userForm.controls.confirmPassword.errors | json}}
    </form>




    I have spend more than hour to identify the cause, but no success. Please help where I am doing wrong. It's working on rxweb.io site : https://rxweb.io/form-validations/compare/validators#basiccomparevalidation










    share|improve this question













    closed as off-topic by Vega, Nkosi, Cœur, AdrianHHH, Makyen Jan 1 at 15:58


    This question appears to be off-topic. The users who voted to close gave this specific reason:


    • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Vega, Nkosi, Cœur, AdrianHHH

    If this question can be reworded to fit the rules in the help center, please edit the question.



















      1












      1








      1


      1






      For compare password, I am using rxwebvalidators and it is working fine when I enter the value in password field after that confirmPassword field. If the confirmPassword field value is incorrect while entering the text then the FormControl become invalid.



      But the problem is if the both controls have same value and I change the value in password field then confirmPassword field will not be invalid. But in actual case It must be invalid.



      I tried in my local project and also create a small replica on stackblitz for you reference : https://stackblitz.com/edit/angular-nriznm?file=src%2Fapp%2Fapp.component.ts



      I do the following:



          this.userForm = this.formBuilder.group({
      password:[''],
      confirmPassword:['',RxwebValidators.compare({fieldName:'password'})]
      })




      Below is my html code :



      <form [formGroup]="userForm">
      password <input type="text" formControlName="password"/><br/>
      compare password <input type="text" formControlName="confirmPassword"/>
      {{userForm.controls.confirmPassword.errors | json}}
      </form>




      I have spend more than hour to identify the cause, but no success. Please help where I am doing wrong. It's working on rxweb.io site : https://rxweb.io/form-validations/compare/validators#basiccomparevalidation










      share|improve this question














      For compare password, I am using rxwebvalidators and it is working fine when I enter the value in password field after that confirmPassword field. If the confirmPassword field value is incorrect while entering the text then the FormControl become invalid.



      But the problem is if the both controls have same value and I change the value in password field then confirmPassword field will not be invalid. But in actual case It must be invalid.



      I tried in my local project and also create a small replica on stackblitz for you reference : https://stackblitz.com/edit/angular-nriznm?file=src%2Fapp%2Fapp.component.ts



      I do the following:



          this.userForm = this.formBuilder.group({
      password:[''],
      confirmPassword:['',RxwebValidators.compare({fieldName:'password'})]
      })




      Below is my html code :



      <form [formGroup]="userForm">
      password <input type="text" formControlName="password"/><br/>
      compare password <input type="text" formControlName="confirmPassword"/>
      {{userForm.controls.confirmPassword.errors | json}}
      </form>




      I have spend more than hour to identify the cause, but no success. Please help where I am doing wrong. It's working on rxweb.io site : https://rxweb.io/form-validations/compare/validators#basiccomparevalidation







      angular angular-reactive-forms






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 1 at 6:58









      Ami VyasAmi Vyas

      596




      596




      closed as off-topic by Vega, Nkosi, Cœur, AdrianHHH, Makyen Jan 1 at 15:58


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Vega, Nkosi, Cœur, AdrianHHH

      If this question can be reworded to fit the rules in the help center, please edit the question.







      closed as off-topic by Vega, Nkosi, Cœur, AdrianHHH, Makyen Jan 1 at 15:58


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Vega, Nkosi, Cœur, AdrianHHH

      If this question can be reworded to fit the rules in the help center, please edit the question.
























          1 Answer
          1






          active

          oldest

          votes


















          2














          Now it is working, I forgot to import 'RxReactiveFormsModule' in main module.



          Register code of 'RxReactiveFormsModule' in main module:






          import { RxReactiveFormsModule } from "@rxweb/reactive-form-validators"
          @NgModule({
          imports: [ BrowserModule, FormsModule,ReactiveFormsModule,RxReactiveFormsModule ],
          declarations: [ AppComponent, HelloComponent ],
          bootstrap: [ AppComponent ]
          })
          export class AppModule { }





          working on stackblitz: https://stackblitz.com/edit/angular-nriznm?file=src%2Fapp%2Fapp.module.ts






          share|improve this answer






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            Now it is working, I forgot to import 'RxReactiveFormsModule' in main module.



            Register code of 'RxReactiveFormsModule' in main module:






            import { RxReactiveFormsModule } from "@rxweb/reactive-form-validators"
            @NgModule({
            imports: [ BrowserModule, FormsModule,ReactiveFormsModule,RxReactiveFormsModule ],
            declarations: [ AppComponent, HelloComponent ],
            bootstrap: [ AppComponent ]
            })
            export class AppModule { }





            working on stackblitz: https://stackblitz.com/edit/angular-nriznm?file=src%2Fapp%2Fapp.module.ts






            share|improve this answer




























              2














              Now it is working, I forgot to import 'RxReactiveFormsModule' in main module.



              Register code of 'RxReactiveFormsModule' in main module:






              import { RxReactiveFormsModule } from "@rxweb/reactive-form-validators"
              @NgModule({
              imports: [ BrowserModule, FormsModule,ReactiveFormsModule,RxReactiveFormsModule ],
              declarations: [ AppComponent, HelloComponent ],
              bootstrap: [ AppComponent ]
              })
              export class AppModule { }





              working on stackblitz: https://stackblitz.com/edit/angular-nriznm?file=src%2Fapp%2Fapp.module.ts






              share|improve this answer


























                2












                2








                2







                Now it is working, I forgot to import 'RxReactiveFormsModule' in main module.



                Register code of 'RxReactiveFormsModule' in main module:






                import { RxReactiveFormsModule } from "@rxweb/reactive-form-validators"
                @NgModule({
                imports: [ BrowserModule, FormsModule,ReactiveFormsModule,RxReactiveFormsModule ],
                declarations: [ AppComponent, HelloComponent ],
                bootstrap: [ AppComponent ]
                })
                export class AppModule { }





                working on stackblitz: https://stackblitz.com/edit/angular-nriznm?file=src%2Fapp%2Fapp.module.ts






                share|improve this answer













                Now it is working, I forgot to import 'RxReactiveFormsModule' in main module.



                Register code of 'RxReactiveFormsModule' in main module:






                import { RxReactiveFormsModule } from "@rxweb/reactive-form-validators"
                @NgModule({
                imports: [ BrowserModule, FormsModule,ReactiveFormsModule,RxReactiveFormsModule ],
                declarations: [ AppComponent, HelloComponent ],
                bootstrap: [ AppComponent ]
                })
                export class AppModule { }





                working on stackblitz: https://stackblitz.com/edit/angular-nriznm?file=src%2Fapp%2Fapp.module.ts






                import { RxReactiveFormsModule } from "@rxweb/reactive-form-validators"
                @NgModule({
                imports: [ BrowserModule, FormsModule,ReactiveFormsModule,RxReactiveFormsModule ],
                declarations: [ AppComponent, HelloComponent ],
                bootstrap: [ AppComponent ]
                })
                export class AppModule { }





                import { RxReactiveFormsModule } from "@rxweb/reactive-form-validators"
                @NgModule({
                imports: [ BrowserModule, FormsModule,ReactiveFormsModule,RxReactiveFormsModule ],
                declarations: [ AppComponent, HelloComponent ],
                bootstrap: [ AppComponent ]
                })
                export class AppModule { }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 1 at 7:52









                Ami VyasAmi Vyas

                596




                596

















                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas