Today, We want to share with you Confirm password validation in Angular 6|7|8|9.In this post we will show you password and confirm password validation in angular 7 reactive form, hear for password and confirm password validation in angular 8 we will give you demo and example for implement.In this post, we will learn about Custom Validator on reactive form for password and confirm password matching getting undefined parameters into Angular 6,7,8,9 with an example.
Confirm password validation in Angular 6|7|8|9
There are the Following The simple About Angular Validation Password and Confirm Password Full Information With Example and source code.
As I will cover this Post with live Working example to develop password and confirm password validation in angular 6 stackblitz, so the password and confirmpassword validation in angular using reactive forms is used for this example is following below.
Angular Validation Password and Confirm Password
src/app/app.component.html
Angular Validation Password and Confirm Password - pakainfo.com
src/app/app.component.ts
import { Component } from '@angular/core'; import { FormBuilder, FormGroup, FormControl, Validators} from '@angular/forms'; import { ConfirmedValidator } from './confirmed.validator'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { form: FormGroup = new FormGroup({}); constructor(private fb: FormBuilder) { this.form = fb.group({ password: ['', [Validators.required]], double_check_pass: ['', [Validators.required]] }, { validator: ConfirmedValidator('password', 'double_check_pass') }) } get f(){ return this.form.controls; } submit(){ console.log(this.form.value); } }
src/app/confirmed.validator.ts
import { FormGroup } from '@angular/forms'; export function ConfirmedValidator(controlName: string, matchingControlName: string){ return (formGroup: FormGroup) => { const control = formGroup.controls[controlName]; const matchingControl = formGroup.controls[matchingControlName]; if (matchingControl.errors && !matchingControl.errors.confirmedValidator) { return; } if (control.value !== matchingControl.value) { matchingControl.setErrors({ confirmedValidator: true }); } else { matchingControl.setErrors(null); } } }
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about password and confirm password validation in angular reactive form.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.