I am having a problem verifing the the password entered in my angular 2 form contains at least one number in it. The other validators work its just this pattern one. the regex I am using I got from Regex: Check if string contains at least one digit
Password:
<div *ngIf="signUpForm.controls['password'].invalid && signUpForm.controls['password'].dirty">
<small *ngIf="signUpForm.controls['password'].errors.minlength">
Please enter a minimum of 6 characters
</small>
<small *ngIf="signUpForm.controls['password'].errors.maxlength">
Password cannot exceed 15 characters
</small>
<small *ngIf="signUpForm.controls['password'].errors.pattern">
Must contain digits
</small>
</div>
inside my form I have the following validator and specifically the pattern I want is to check if the string entered contains a number
"password":["", [
Validators.required,
Validators.minLength(6),
Validators.maxLength(15),
Validators.pattern('/\d')
]
]
The errors.patters ngIf never goes away even if there are numbers in the field, not sure what I am doing wrong. My other pattern validators for other fields work.