Compare password in angular reactive forms [closed]
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
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.
add a comment |
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
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.
add a comment |
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
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
angular angular-reactive-forms
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
add a comment |
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
add a comment |
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
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 { }
answered Jan 1 at 7:52
Ami VyasAmi Vyas
596
596
add a comment |
add a comment |