paganotti
paganotti

Reputation: 5661

how check if tinymce editor is empty and forced_root_block option is set as div

How can I check if tinymce has empty content? I'm testing it:

http://jsfiddle.net/Jjw2U/

Tinymce editor doesn't return me a empty string because it set by default a empty tag

 <div>&nbsp;</div>

It put empty div row because I set forced_root_block option as 'div', but I don't want change forced_root_block.

I try with regex

    editorContent.replace("/(<div>&nbsp;</div>)+/gi"," "); 
    editorContent = editorContent.replace(/^\s+|\s+$/g,"");

but It doesn' work. I wrong regex?

How can I do?

Upvotes: 4

Views: 3688

Answers (1)

ultranaut
ultranaut

Reputation: 2140

Just add that to your test:

if (editorContent == '' || editorContent == null || editorContent == '<div>&nbsp;</div>')

It's not strictly speaking empty content, but it indicates the user hasn't made any meaningful changes to the textarea, which is I assume what you want to know.

Upvotes: 1

Related Questions