My current password validation pattern does not allow white space and requires at least 6 characters: /[^\s]+.{6,}/;
I specifically need 6 characters that are anything except a space.
However, this pattern is not functioning as expected.
const passwordreg = this.registrationForm.value.passwordreg;
const passwordpattern = /[^\s]+.{6,}/;
if (passwordreg === null || passwordreg === undefined || passwordreg === '' ) {
this.showMessagesregist = true;
this.errorMessage = 'Please Enter Password';
return;
}
else if(!passwordpattern.test(passwordreg)){
this.showMessagesregist = true;
this.errorMessage = 'Password must be at least 6 characters.';
return;
}
<input [type]="fieldTextType ? 'text' : 'password'" autocomplete="passwordreg" formControlName="passwordreg" class="form-control mb-2" placeholder="Enter Password">