无法使用angular.js验证电子邮件字段

时间:2015-10-29 04:12:37

标签: javascript angularjs validation email

我在使用Angular.js验证电子邮件时遇到一个问题。在我的代码中,我使用ng-message来显示验证消息。对于某些无效类型的电子邮件(e.g-@abc.com),它显示了验证消息,但在某些情况下,如果我输入这样的.com@abc它没有显示任何验证消息。我在下面解释我的代码。

<div class="input-group bmargindiv1 col-md-12">
    <span class="input-group-addon ndrftextwidth text-right" style="width:180px">Email Id :</span>
    <div ng-class="{ 'has-error': billdata.email.$touched && billdata.email.$invalid }">
    <input type="email" name="email" id="contactno" class="form-control" placeholder="User email" ng-model="user_email" >
 </div>
</div>
<div class="help-block" ng-messages="billdata.email.$error" ng-if="billdata.email.$touched">
<p ng-message="email" style="color:#F00;">This needs to be a valid email</p>
</div>

此处我需要此字段将使用正确的电子邮件格式(i.e-abc@gmail.com)进行验证。请帮我解决此问题。

0 个答案:

没有答案