【发布时间】:2017-08-21 15:02:53
【问题描述】:
表格:
<div class="group">
<label for="email" class="label">Email Address</label>
<input id="email" type="text" class="input" name="email" pattern="/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/" [(ngModel)]="user.email"
#email="ngModel" required>
<div *ngIf="email.errors && (email.dirty || email.touched)" class="alert alert-danger">
<div [hidden]="!email.errors.required">
email invalid
</div>
</div>
</div>
我尝试使用正则表达式模式,但它没有工作,它没有显示任何错误,并且创建的用户没有有效的电子邮件地址。我从 stackoverflow 的其他 angular2 电子邮件验证答案中使用了这种模式。
【问题讨论】:
-
您可能需要考虑hackernoon.com/… 和hackernoon.com/…
标签: angular