why520crazy / angular-w5c-validator

a simple plugin for angular.js form validation
http://why520crazy.github.io/angular-w5c-validator
468 stars 162 forks source link

关于非表单元素怎么验证 #72

Closed bankly closed 8 years ago

bankly commented 8 years ago

eg:

<ul ng-repeat="employee in arrange.employees  track by $index">
                                        <li  ng-model="employee.employeeName"  **required**   >
                        <div ng-if="employee.headimgurl==null">
                            <img  ng-src="images/employee_user.png" >
                        </div>
                        <div ng-if="employee.headimgurl!=null">
                            <img   ng-src="{{employee.headimgurl}}" >
                        </div>
                    </li>
</ul>
why520crazy commented 8 years ago

非表单元素都没有输入,为啥需要验证,在界面显示之前就应该验证好了的, 你这 li 标签上加 ng-model 有啥意义,哪里可以修改 employee.employeeName,如果要做就设置一个隐藏的元素做验证

why520crazy commented 8 years ago

通过这个元素的valid属性判断是否验证通过,然后显示错误的样式即可