【发布时间】:2018-03-30 20:18:23
【问题描述】:
您好,使用 angular 2 作为密码字段我必须设置“密码应至少包含 1 个大写字母、1 个小写字母、1 个数字、1 个特殊字符、最少 8 个字符和最多 16 个字符”
因为我做了“最少 8 个字符,最多 16 个字符”。
但我无法为剩余的东西设置至少 1 个大写字母、1 个小写字母、1 个数字、1 个特殊字符。
<div class ="form-group">
<label> Password </label>
<input class ="form-control" name ="password" #password="ngModel" [(ngModel)] = "angulaService.selectedAngula.password"
placeholder="password" minlength="8" maxlength="16" >
<div class="form-control-feedback"
*ngIf="password.errors && (password.dirty || password.touched)">
<p *ngIf="password.errors.required">Password is required</p>
<p *ngIf="password.errors.minlength">Password must be min 8 characters long</p>
</div>
<div class="form-control-feedback"
*ngIf="password.errors && (password.dirty || password.touched)">
<p *ngIf="password.errors.required">Password is required</p>
<p *ngIf="password.errors.maxlength">Password should not be greater than 16 characters long</p>
</div>
</div>
请帮帮我
提前致谢
【问题讨论】:
-
使用异步验证器。
-
这是针对 Angular 1.x 还是 2.x+ 的?请确保不要混淆标签。
-
@sundeep:请更正标签,它们是混合的。
-
这适用于 Angular 2.x+
标签: angular angular-validation