如何停止bootstrapValidator来验证隐藏的输入字段?

时间:2019-11-25 10:13:52

标签: javascript bootstrapvalidator

我想在表单中实现bootstrapValidator,我也有一些隐藏的输入字段,但它也在验证这些内容,我想停止此操作... 我的表格代码

<form id="create_contract_group" method="post"

 - List item

>
<div class="row">
  <div class="form-group">
    <label class="col-md-4 control-label"><b>{!!Lang::get('site_lang.contract_group')!!}</b></label>
       <div class="col-md-8">
          <input type="text" class="form-control" name="title" placeholder=" Title of the contract group"/>
          <input type="text" class="form-control" name="id" style="display:none">
       </div>
    </div>
 </div>
</form>

我的脚本

<script>
$(document).ready(function() {
    $('#create_contract_group').bootstrapValidator({
            excluded: ':disabled',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                title: {
                    validators: {
                        notEmpty: {
                            message: 'Title is required.'
                        },
                        validatorName: validatorOptions
                    }
                },
            }
        });
});
</script>

1 个答案:

答案 0 :(得分:2)

您可以在boostrapValidator中使用排除设置,如下所示:

$('#create_contract_group').bootstrapValidator({
            excluded: [':disabled', ':hidden', ':not(:visible)'],
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                title: {
                    validators: {
                        notEmpty: {
                            message: 'Title is required.'
                        },
                        validatorName: validatorOptions
                    }
                },
            }
        });