2013-05-30 87 views
0

我要檢查CK文本編輯的驗證它是否是空的或不如何檢查CKEditor中是否有一些HTML標籤?

我使用這個代碼: -

if ($(".cleditorToolbar:eq(0)").next().next('iframe').contents().find('body').getInnerText().trim() == '') { 
     $('span[id$=span_0]').html('Please enter question text'); 
     return false; 
    } 

當我輸入的CK編輯器,它工作正常一些文本,但是當我粘貼一些圖像,它不驗證HTML標籤,即標籤,如何在Ck編輯器中驗證html標籤和文本文件,請幫助我?

回答

2

你有沒有嘗試一下本作的 「空考」:

if(CKEDITOR.instances.yourInstance.getData() === '') { 
    // It's empty 
} 

我認爲你可以使用這樣的 '數據處理器':

CKEDITOR.replace('editor1', { 
    on: { 
     pluginsLoaded: function(event) { 
     event.editor.dataProcessor.dataFilter.addRules({ 
      elements: { 
       a: function(element) { 
        var attr = element.attributes; 
        if(attr.href && attr.href.indexOf('#') === -1) { 
        element.attributes.target = '_blank'; 
        } 
       }, 
       // remove script 
       script: function(element) { 
        return false; 
       } 
      } 
     }); 
     } 
    } 
}); 

Documentation

相關問題