84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
angularjs里面提供基础的表单验证,比如ng-minlength之类的属性,然后用form.inputname.$valid就可以进行判断是否验证通过
ng-minlength
form.inputname.$valid
但是像checkbox这种多选框怎么验证啊?要验证至少选中一个,有没有内置的,感觉这种应该不用写很复杂吧?
checkbox
I came up with the method myself, see the blog: angularjs form verification checkbox
html<input type="checkbox" ng-model="form.cb1" ng-required="form.cb1 || form.cb2 || form.cb3"> <input type="checkbox" ng-model="form.cb2" ng-required="form.cb1 || form.cb2 || form.cb3"> <input type="checkbox" ng-model="form.cb3" ng-required="form.cb1 || form.cb2 || form.cb3">
html
<input type="checkbox" ng-model="form.cb1" ng-required="form.cb1 || form.cb2 || form.cb3"> <input type="checkbox" ng-model="form.cb2" ng-required="form.cb1 || form.cb2 || form.cb3"> <input type="checkbox" ng-model="form.cb3" ng-required="form.cb1 || form.cb2 || form.cb3">
ngRequired is too long, just bind a function to return boolean.
ngRequired
I came up with the method myself, see the blog: angularjs form verification checkbox
ngRequired
is too long, just bind a function to return boolean.