简体   繁体   中英

How can validate ck editor using javascript?

I'm trying to validate ck editor ( textarea ) but failed, can anyone let me know where the problem in following code, is this possible that ck editor validate by following code?

Javascript

$(document).ready(function(){
       $("#manageForm").validate(
        {
          debug: false,
            rules: { 
                description:{

                 required:true,
                 minlenght:10
                }
             }
        });
    });

HTML

<form name="manageForm" id="manageForm" method="post" action="" enctype="multipart/form-data">
    <textarea name="description" id="description" class="span6 autogrow"></textarea>
</form>

You can use jquery to validate ck editor: my solution is using below code:

  $(document).ready(function(){

            $("#manageForm").validate(
            {
              debug: false,
                rules: { 

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

                         minlength:10
                    }
                },
                messages:
                    {

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


                    }
                }
            });
        });

I have edited your code : please look at this jsfiddle demo link

有一个错字: minlenght:10应该是minlenght:10 minlength:10

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM