Jquery验证不能与ckeditor工作 [英] Jquery validation not working with ckeditor

查看:144
本文介绍了Jquery验证不能与ckeditor工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery来验证窗体..但是当我使用CKeditor并尝试使用jQuery验证它时,它不工作。



这里是HTML代码片段

 < form class =form-horizo​​ntalrole =formname =f3id =f3 > 
< div class =col-xs-8>
< textarea class =ckeditorname =cktextid =cktext>< / textarea>
< / div>
< button type =submitclass =btn btn-default btn-success>提交< / button>
< / form>

以下是表单验证码

 < script> 
$(document).ready(function(){
$(#f3)。validate(
{
debug:false,
rules:{
cktext:{

必需:true,
minlenght:10
}
}
});
< / script>

FYI:对其他表单字段的jquery验证期望 ckeditor textarea



任何建议..摆脱这个问题..

解决方案

最后我发现我的问题的答案...



我更改了ignore属性的值,默认值为:hidden value。 as CKEDITOR隐藏textarea jQuery验证不验证元素:

  ignore:[] 



只是我改变了验证脚本如下:

 code> $(document).ready(function(){

$(#f3)。validate(
{
ignore:[],
debug:false,
rules:{

cktext:{
required:function()
{
CKEDITOR.instances.cktext.updateElement );
},

minlength:10
}
},
消息:
{

cktext :{
必需:请输入文本,
minlength:请输入10个字符


}
}
} ;
});

HTML片段是

 < form class =form-horizo​​ntalrole =formname =f3id =f3> 
< div class =col-xs-8>
< textarea class =ckeditorname =cktextid =cktext>< / textarea>
< / div>
< button type =submitclass =btn btn-default btn-success>提交< / button>
< / form>

我发现这个答案在这里



感谢所有...


I am using jQuery to validate forms.. but when I use CKeditor and try to validate it using jQuery, it's not working.

Here is the snippet of HTML code

  <form class="form-horizontal" role="form" name="f3" id="f3" >
   <div class="col-xs-8">
       <textarea class="ckeditor" name="cktext" id="cktext"></textarea>
   </div>
    <button type="submit" class="btn btn-default btn-success">Submit</button>
  </form>

Here is the form validation code

    <script>
           $(document).ready(function(){
           $("#f3").validate(
            {
              debug: false,
                rules: { 
                    cktext:{

                     required:true,
                     minlenght:10
                    }
                 }
            });
        });
      </script>

FYI : jquery validation working for other form fields expect the ckeditor textarea filed

Any suggestions.. to get rid of this problem..

解决方案

Finally i found the answer to my question...

I changed the value of ignore property which by default holds :hidden value. as CKEDITOR hides the textarea jQuery validation doesn't validate the element:

   ignore: []  

Just i changed the validation script as follows..

     $(document).ready(function(){

            $("#f3").validate(
            {
                ignore: [],
              debug: false,
                rules: { 

                    cktext:{
                         required: function() 
                        {
                         CKEDITOR.instances.cktext.updateElement();
                        },

                         minlength:10
                    }
                },
                messages:
                    {

                    cktext:{
                        required:"Please enter Text",
                        minlength:"Please enter 10 characters"


                    }
                }
            });
        });

HTML snippet is

   <form class="form-horizontal" role="form" name="f3" id="f3" >
     <div class="col-xs-8">
        <textarea class="ckeditor" name="cktext" id="cktext"></textarea>
    </div>
     <button type="submit" class="btn btn-default btn-success">Submit</button>
   </form>

As i found this answer in Here

Thanks to all...

这篇关于Jquery验证不能与ckeditor工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆