【发布时间】:2016-01-22 06:43:39
【问题描述】:
<label class="item item-input margin5px">
<input type="email" name="email" class="form-control" placeholder="Email" ng-model="user.email" ng-minlength=5 ng-maxlength=100 required>
</label>
我的电子邮件字段有 minlength、maxlength 和必需的验证。如果其中任何一个验证失败,我想添加一个类“有错误”或添加某种样式。任何帮助将非常感激。
【问题讨论】:
-
到目前为止你尝试了什么?
-
我曾尝试使用 ng-class="{ 'has-error': userForm.email.$invalid }" 和 ng-class="{ 'has-error': userForm.email.$ error.required }" 和 ng-style 也是。
标签: angularjs angularjs-validation