🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

angular2-text-equality-validator

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular2-text-equality-validator

Angular 2 text equality validator, compare password

2.0.0
latest
Source
npm
Version published
Weekly downloads
12
50%
Maintainers
1
Weekly downloads
 
Created
Source

Angular 2 compare text fields validator - useful for password match fields

npm install --save angular2-text-equality-validator import { EqualTextValidator } from "angular2-text-equality-validator"; Add the directive to module

Model driven

 <form novalidate [formGroup]="signUpForm">
  <input type="text"
         placeholder="password"
         formControlName="password"
         validateEqualTo="repeatPassword">
  <input type="text" placeholder="confirm" formControlName="repeatPassword">
  <input type="submit" value="Submit" [disabled]="signUpForm.invalid">
  <p *ngIf="signUpForm.get('password').hasError('validateEqual')">Passwords don't match</p>
</form>
export class AppComponent {
  signUpForm: FormGroup;

  constructor(public fb: FormBuilder) {
    this.signUpForm = this.fb.group({
      password: [""],
      repeatPassword: [""]
    });
  }
}

Template driven

<form novalidate #form="ngForm">
  <input type="text"
         placeholder="password"
         ngModel
         validateEqualTo="repeatPassword"
         name="password"
         required
         #passwordControl="ngModel"
  >
  <input type="text" placeholder="confirm" name="repeatPassword" ngModel required>
  <input type="submit" value="Submit" [disabled]="form.invalid">
 <p *ngIf="passwordControl.errors?.validateEqual">Passwords don't match</p>
</form>

Keywords

angular

FAQs

Package last updated on 24 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts