Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular.js required at least one checkbox [duplicate]

I wouldn't be surprised if this is a duplicate however I can't find anything simple along the lines of what I need.

All I need is the user to be required to choose at least one checkbox but I'm baffled how to accomplish this.

    <input type="checkbox" ng-model="myForm.first" /> First <br />
    <input type="checkbox" ng-model="myForm.second" />Second <br />
    <input type="checkbox" ng-model="myForm.third" /> Third
like image 302
KingKongFrog Avatar asked Nov 17 '14 18:11

KingKongFrog


1 Answers

<input type="checkbox" ng-model="myForm.first" ng-required="myForm.first || myForm.second || myForm.third" /> First <br />
<input type="checkbox" ng-model="myForm.second" ng-required="myForm.first || myForm.second || myForm.third"/>Second <br />
<input type="checkbox" ng-model="myForm.third" ng-required="myForm.first || myForm.second || myForm.third"/> Third
like image 137
khalid13 Avatar answered Oct 17 '22 11:10

khalid13