Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.form = fb.group({
- username: ['', Validators.compose([Validators.required])],
- fullName: ['', Validators.compose([Validators.required])],
- password: ['', Validators.compose([Validators.required])],
- confirmPassword: ['', Validators.required],
- }, {validator: matchingPasswords('password', 'confirmPassword')});
- export function matchingPasswords(passwordKey: string, passwordConfirmationKey: string) {
- return (group: FormGroup) => {
- let password = group.controls[passwordKey];
- let passwordConfirmation = group.controls[passwordConfirmationKey];
- if (password.value !== passwordConfirmation.value) {
- return passwordConfirmation.setErrors({mismatchedPasswords: true})
- }
- }
- <div class="form-group">
- <input [formControl]="confirmPassword" class="form-control checking-field" type="password">
- <span class="help-block text-danger" *ngIf="form.get('password').touched && form.get('password').hasError('required')">
- </div>
- <div class="form-group">
- <input class="custom-control-input checkbox-main" type="checkbox" [(ngModel)]="policyButtonValue" [ngModelOptions]="{standalone: true}" ngDefaultControl>
- <span class="custom-control-indicator"></span>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement