How to check whether CKEditor has some text in it?

后端 未结 6 1530
时光取名叫无心
时光取名叫无心 2021-02-04 02:08

I have an HTML form with a few fields. One of them is a textarea managed by CKEditor.

When the user wants to submit the form, I want to check whether he entered values

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-04 02:13

    You can use the following snippet to check if the ckeditor has some text.

    var _contents = CKEDITOR.instances.editor1.document.getBody().getText();
    if (_contents == '') {
        alert('Please provide the contents.') ;
    }
    

提交回复
热议问题