【问题标题】:How to revalidate ckeditor fields after value enters into the fields值输入字段后如何重新验证ckeditor字段
【发布时间】:2020-02-26 11:58:35
【问题描述】:

我想使用 bootstrapvalidator 重新验证 ckeditors 字段。

Option1: {
    validators: {
        notEmpty: {
            message: 'The A is required'
        }
    }
},
Option2: {
    validators: {
        notEmpty: {
            message: 'The B is required'
        }
    }
},
Option3: {
    validators: {
        notEmpty: {
            message: 'The C is required'
        }
    }
},
Option4: {
    validators: {
        notEmpty: {
            message: 'The D is required'
        }
    }
},                    
QBQuestion: {
    validators: {
        notEmpty: {
            message: 'The QBQuestion is required and cannot be empty'
        }
    }
}

这是我的 div 代码:

<div class="row form-group">
    <div class="col-lg-12">
        <lable>Question</lable>
        <textarea name="QBQuestion" id="QBQuestion" rows="10" cols="80" class="form-control"></textarea>
    </div>
</div>

<div class="row form-group">
     <div class="col-lg-3">
         <lable>A</lable>
         <textarea name="Option1" id="Option1" rows="10" cols="80" class="form-control"></textarea>
     </div>
     <div class="col-lg-3">
         <lable>B</lable>
         <textarea name="Option2" id="Option2" rows="10" cols="80" class="form-control"></textarea>
     </div>
     <div class="col-lg-3">
         <lable>C</lable>
         <textarea name="Option3" id="Option3" rows="10" cols="80" class="form-control"></textarea>
     </div>
     <div class="col-lg-3">
         <lable>D</lable>
         <textarea name="Option4" id="Option4" rows="10" cols="80" class="form-control"></textarea>
     </div>
 </div>

这里我使用 bootstrapvalidator 进行验证。输入一些文本后,这些字段没有得到重新验证。这里我有五个 ckeditor 字段。如果有数据,我需要验证所有五个字段。

【问题讨论】:

    标签: jquery bootstrapvalidator


    【解决方案1】:

    Ckeditor 脚本隐藏了文本区域,因此验证将不起作用,请在 Jquery 中尝试此代码

     $(document).ready(function(){
    
            $("#form").validate(
            {
              ignore: [],
              debug: false,
                rules: { 
    
                    Option1:{
                         required: function() 
                        {
                         CKEDITOR.instances.Option1.updateElement();
                        },
    
                         minlength:10
                    }
                },
                messages:
                    {
    
                    Option1:{
                        required:"Please enter Text",
                        minlength:"Please enter 10 characters"
    
    
                    }
                }
            });
        });
    

    注意ignore: [] 对激活验证很重要。

    【讨论】:

      猜你喜欢
      • 2019-08-29
      • 1970-01-01
      • 2021-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多