angular2中的密码验证,满足以下条件:

Password validation in angular 2, satisfying the following conditions:

我尝试了以下方法:

<div class="form-group row">
                <label class="col-md-2 col-form-label" for="passcode">Password *</label>
                <div class="col-md-3">
                    <input class="form-control" type="password" placeholder="Password" formControlName="passCode" [(ngModel)]="userDetails.passCode" pattern="^(?=.*\d)(?=.*[a-z])(?!.*\s).{7,12}$">
                    <div *ngIf="userAdd.controls['passCode'].hasError('required')&&(userAdd.controls.passCode?.dirty ||userAdd.controls.passCode?.touched)" class="alert alert-danger">
                        {{errorMessageForRequired}}
                    </div>
                    <div *ngIf="userAdd.controls['passCode'].errors && userAdd.controls['passCode'].errors.pattern" class="alert alert-danger">
                        Passcode must contain only letters, numbers and underscores (7-12 characters)
                    </div>
                </div>
            </div>

请帮帮我

我觉得你的 regex 有点不对劲。
通过:Qwert!1 符合要求。

<form>
<input type="text" pattern="((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\W]).{7,64})" required placeholder="Qwert!1"/>
<input type="submit" />
</form>