Search code examples
javascriptckeditorckeditor4.x

ckeditor character count on multiple textareas with wordcount plugin


I have multiple ckeditor textareas on single page, and I need to limit character count for all of them combined. Is it possible to do it with ckeditor, or is it possible to get that value to javascript variable so I can add them and create alert that way?


Solution

  • If you know the ID of each CKEditor instances then you can use the getData method or you can use CKEDITOR.instances to get all instances on a page and have logic in place as needed.

    for (var id in CKEDITOR.instances) {
         console.log(CKEDITOR.instances[id].getData().replace(/<[^>]*>|\s/g, '').length);
    }