Bootstrap 验证器检查多个空复选框

Boostrap validator check for empty checkbox from multiple

我有多个从名称为 array[] 的数据库中获取的 chekckbox。如何为多个同名复选框设置空检查?下面是一些不同输入的例子,它不工作,但通常应该工作。

这是 documentation 这个

通常应该与

一起工作
'array[]': {
      validators: {
        notEmpty: {
          message: 'The array is required'
        },
        choice: {
          min: 1,
          max: 20,
          message: 'Please choose 1 - 20 topics'
        }
      }
}

$(document).ready(function() {
  $('#formz').bootstrapValidator({
      message: 'This value is not valid',
      //live: 'submitted',
      feedbackIcons: {
        valid: 'glyphicon',
        invalid: 'glyphicon',
        validating: 'glyphicon glyphicon-refresh'
      },
      fields: {
        'firstinput': {
          validators: {
            notEmpty: {
              message: 'Choose from select'
            }
          }
        },
        'secondinput': {
          validators: {
            notEmpty: {
              message: 'type any text'
            }
          }
        },
        'array[]': {
          validators: {
            notEmpty: {
              message: 'The array is required'
            },
            choice: {
              min: 1,
              max: 20,
              message: 'Please choose 1 - 20 topics'
            }
          }
        },
      },
      onSuccess: function(e, data) {
        $(document).ready(function() {
          $('#spins').show();

        });

      }
    })
    .on('error.form.bv', function(e) {
      console.log('error.form.bv');

      var $form = $(e.target);
      console.log($form.data('bootstrapValidator').getInvalidFields());

      data.bv.disableSubmitButtons(false);
    })

    .on('error.field.bv', function(e, data) {
      console.log('error.field.bv -->', data);
      data.bv.disableSubmitButtons(false);
    });
});
<form method='post' action='' enctype="multipart/form-data" name='formz' id='formz'>
  <select name='firstinput'>
    <option value=''> first </option>
    <option value='1'> second </option>
    <option value='2'> third </option>
  </select>

  <input type="text" name="secondinput" />

  <input type="checkbox" name="array[]" />
  <input type="checkbox" name="array[]" />
  <input type="checkbox" name="array[]" />
  <input type="checkbox" name="array[]" />
  <input type="checkbox" name="array[]" />
  <input type="checkbox" name="array[]" />
  <input type="checkbox" name="array[]" />
  <input type="checkbox" name="array[]" />
  <button type="submit" class="btn btn-success btn-block">Apply</button>
</form>

我发现错误。所有复选框都应在 <div class="form-group"> 内,否则它不适用于 bootstrapvalidator