Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. this.form = fb.group({
  2. username: ['', Validators.compose([Validators.required])],
  3. fullName: ['', Validators.compose([Validators.required])],
  4. password: ['', Validators.compose([Validators.required])],
  5. confirmPassword: ['', Validators.required],
  6. }, {validator: matchingPasswords('password', 'confirmPassword')});
  7.  
  8. export function matchingPasswords(passwordKey: string, passwordConfirmationKey: string) {
  9. return (group: FormGroup) => {
  10. let password = group.controls[passwordKey];
  11. let passwordConfirmation = group.controls[passwordConfirmationKey];
  12. if (password.value !== passwordConfirmation.value) {
  13. return passwordConfirmation.setErrors({mismatchedPasswords: true})
  14. }
  15. }
  16.  
  17. <div class="form-group">
  18. <input [formControl]="confirmPassword" class="form-control checking-field" type="password">
  19. <span class="help-block text-danger" *ngIf="form.get('password').touched && form.get('password').hasError('required')">
  20. </div>
  21. <div class="form-group">
  22. <input class="custom-control-input checkbox-main" type="checkbox" [(ngModel)]="policyButtonValue" [ngModelOptions]="{standalone: true}" ngDefaultControl>
  23. <span class="custom-control-indicator"></span>
  24. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement