mercredi 6 avril 2016

Checkbox at least one click validation before submit

I am currently checking the user input form before submit. i need to check if user click one of this checkbox before submitting the form.

<div class="form-group has-feedback" ng-class="addUser.scope.$valid ? 'has-success' : 'has-error';">
   <label for="scope" >Scope</label><br>
    <input type="checkbox" ng-model="user.scope.admin" name="scope[]" value="admin"> Admin <br>
    <input type="checkbox" ng-model="user.scope.app" name="scope[]" value="app" > App <br>
    <input type="checkbox" ng-model="user.scope.redemption" name="scope[]" value="redemption" > Redemption <br>
   <br>
</div>

It works perfectly with radio button and input text when i set the input type required. but it doesn't apply to checkbox. Anyone can help me?

<div class="form-group has-feedback" ng-class="addUser.confirmpassword.$valid ? 'has-success' : 'has-error';" ng-hide="hideField">
 <label class="control-label" for="confirmpassword">Re-enter Password</label>
  <input type="password" class="form-control" name="confirmpassword" ng-model="user.confirmpassword" required ng-minlength="5">
  <span class="glyphicon form-control-feedback" ng-class="addUser.confirmpassword.$valid ? 'glyphicon-ok' : 'glyphicon-remove';"></span>
</div>

<div class="form-group has-feedback" ng-class="addUser.status.$valid ? 'has-success' : 'has-error';">
 <label for="status">Status</label><br>
  <input type="radio" ng-model="user.status" name="status" value="1" required> Active
  <input type="radio" ng-model="user.status" name="status" value="0" required> Inactive<br>
</div>




Aucun commentaire:

Enregistrer un commentaire