angularjs - Validating checkboxes angular -


how validate checkboxes, @ least 1 must checked, if not, there has message or alert

<div class="form-group" ng-class="{ 'has-error' : actionsaddform.active.$invalid && !actionsaddform.active.$pristine }">     <label class="control-label col-sm-2">days*</label>     <div class="col-sm-10">         <label>monday           <input type="checkbox" ng-model="actions.value1">         </label>         <label>tuesday           <input type="checkbox" ng-model="actions.value2">         </label>         <label>wednesday           <input type="checkbox" ng-model="actions.value3">         </label>         <label>thursday           <input type="checkbox" ng-model="actions.value4">         </label>         <label>friday           <input type="checkbox" ng-model="actions.value5">         </label>         <label>saturday           <input type="checkbox" ng-model="actions.value6">         </label>         <label>sunday           <input type="checkbox" ng-model="actions.value7">         </label>     </div> 

this can done :

<div ng-hide="actions.value1 || actions.value2 || actions.value3...">     have error  </div> 

otherwise, if want able use $valid,... have create custom directive inheriting ngmodelcontroller, , adding custom validators inside : https://docs.angularjs.org/api/ng/type/ngmodel.ngmodelcontroller


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -