**AngularJS**
<tr>
<td>E-mail:</td>
<td><input id="email" type="email" ng-model="regform.email" name="uEmail" required/></td>
</tr>
<tr>
<td></td>
<td>
<div ng-show="form.$submitted || form.uEmail.$touched">
<span ng-show="form.uEmail.$error.required">Enter your email.</span>
<span ng-show="form.uEmail.$error.email">This is not a valid email.</span>
</div>
</td>
</tr>
在这里,当检查电子邮件ab @ c和[email protected]时,其结果为true。如何正确验证电子邮件。
<tr>
<td>E-mail:</td>
<td><input id="email" type="text" ng-model="regform.email" name="uEmail" ng-pattern="EMAIL_REGEXP" required="" /></td>
</tr>
<tr>
<td></td>
<td>
<div ng-show="form.$submitted || form.uEmail.$touched">
<span ng-show="form.uEmail.$error.required">Enter your email.</span>
<span ng-show="form.uEmail.$error.pattern">This is not a valid email.</span>
</div>
</td>
</tr>
使用此代码
$ scope.EMAIL_REGEXP = /^\w+([.-]?\w+)@ \ w +([.-]?\ w +)(。\ w {2,3})+ $ /;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句