复选框在提交前至少进行一次点击验证

时间:2016-04-07 02:48:04

标签: javascript html angularjs forms checkbox

我目前正在提交之前检查用户输入表单。我需要检查用户是否在提交表单之前单击此复选框之一。

<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>

当我设置所需的输入类型时,它与单选按钮和输入文本完美配合。但它不适用于复选框。有人可以帮帮我吗?

<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>

0 个答案:

没有答案