Using checkboxes and required with AngularJS

后端 未结 5 1658
独厮守ぢ
独厮守ぢ 2021-01-31 08:20

I\'ve tried to use the html5 required attribute for my group of checkboxes but I don\'t find a nice way to implement it with ng-form.

When a checkbox is che

5条回答
  •  误落风尘
    2021-01-31 09:03

    If you want the submit button disabled if no choice is selected the easiest way is to check the length of the array in the ng-disabled attribute, without setting the required attribute

    
    

    See here for updated fiddle

    Another way to do this would be to check the array length in the ng-required attribute of the checkboxes

    
    

    Second fiddle

提交回复
热议问题