简体   繁体   中英

How to validate the Ckeditor using JQuery

I am new in javascript and I am developing a project into CodeIgniter. Actually, I face a problem into CKEditor validation.When I fill all field and Click on the submit button then one message show CkEditor is required field But when I again click on the submit button data successfully submitted.

I don't know how to resolve this problem.I already search so many things But my Problem is same. I using this code But this is giving an error getData() is not Defined I don't know what is getdata and where I have to use this.

function CheckForm(theForm) 
{
    textbox_data = CKEDITOR.instances.mytextbox.getData();
    if (textbox_data==='')
    {
        alert('please enter a comment');
    }
}

change this

textbox_data = CKEDITOR.instances.mytextbox.getData();

to

textbox_data = CKEDITOR.instances['mytextbox'].getData();

in [] there should be id of the textbox.

NOTE: Don't forget to add CKEditor JS.

I guess might be two mistakes you are doing

  1. declared form later and would have written JavaScript before

  2. getdata() is simple jQuery function to get anything within CKeditor text box

Please refer complete CKeditor documentation here .

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