Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 91ef1e3

Browse filesBrowse files
committed
Added password match validation
1 parent 7e8c4b7 commit 91ef1e3
Copy full SHA for 91ef1e3

2 files changed

+20-3Lines changed: 20 additions & 3 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/app/auth/components/sign-up/sign-up.component.html‎

Copy file name to clipboardExpand all lines: src/app/auth/components/sign-up/sign-up.component.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h3 class="panel-title">Signup to {{title}}</h3>
4343
<div class="register-input-item">
4444
<input type="password" class="register-user-input-password register-user-input" name="password_confirmation" formControlName="password_confirmation"
4545
placeholder="Confirm Password" autocomplete="off">
46-
<div *ngIf="signUpForm.get('password_confirmation').errors && signUpForm.get('password_confirmation').touched">
46+
<div *ngIf="(signUpForm.get('password_confirmation').errors || signUpForm.hasError('mismatchedPasswords')) && signUpForm.get('password_confirmation').touched">
4747
<span class="register-error-icon">!</span>
4848
<p class="register-error-message">{{signUpForm.get('password_confirmation').errors.msg || 'Password must match'}}</p>
4949
</div>
Collapse file

‎src/app/auth/components/sign-up/sign-up.component.ts‎

Copy file name to clipboardExpand all lines: src/app/auth/components/sign-up/sign-up.component.ts
+19-2Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ export class SignUpComponent implements OnInit, OnDestroy {
7373
'password': [password, Validators.compose([Validators.required, Validators.minLength(6)]) ],
7474
'password_confirmation': [password_confirmation, Validators.compose([Validators.required, Validators.minLength(6)]) ],
7575
'mobile': [mobile, Validators.compose([Validators.required, Validators.minLength(10), Validators.maxLength(10),Validators.pattern('[0-9]{10}')]) ],
76-
'gender': [gender, Validators.required],
77-
});
76+
'gender': [gender, Validators.required]
77+
},{validator: this.matchingPasswords('password', 'password_confirmation')}
78+
);
7879
}
7980

8081
redirectIfUserLoggedIn() {
@@ -88,4 +89,20 @@ export class SignUpComponent implements OnInit, OnDestroy {
8889
ngOnDestroy() {
8990
if (this.registerSubs) { this.registerSubs.unsubscribe(); }
9091
}
92+
93+
matchingPasswords(passwordKey: string, confirmPasswordKey: string) {
94+
return (group: FormGroup): {[key: string]: any} => {
95+
let password = group.controls[passwordKey];
96+
let confirmPassword = group.controls[confirmPasswordKey];
97+
98+
if (password.value !== confirmPassword.value) {
99+
return {
100+
mismatchedPasswords: true
101+
};
102+
}
103+
}
104+
}
105+
106+
107+
91108
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.