Validating TinyMCE for empty inputs
<p>I use TinyMCE as a very effective WYSIWYG editor.</p>

<p>There are no problems with the editor functionally. The problem comes when trying to determine if its empty.</p>

<hr>

<h2>Problem</h2>

<p>I need to validate the input of the TinyMCE textarea to ensure that something has been entered before I submit the form. </p>

<h2>What I have tried</h2>

<p>I have discovered on <a href="https://stackoverflow.com/questions/8749179/how-do-i-validate-a-tinymce-editor-if-it-is-blank-by-appending-a-string-next-to">this</a> question that users have had success with this using the following statement</p>

<pre><code>var editorContent = tinyMCE.get('tinyeditor').getContent();
if (editorContent == '')
{
    // Editor empty
}
</code></pre>

<p>For me there is a problem with this because instead of returning an empty string, the string returned looks like this (While empty):</p>

<pre><code>"&lt;!DOCTYPE html&gt;↵&lt;html&gt;↵&lt;head&gt;↵&lt;/head&gt;↵&lt;body&gt;↵↵&lt;/body&gt;↵&lt;/html&gt;"
</code></pre>

<p>I even tried evaluating the string like this</p>

<pre><code>if (editorContent == "&lt;!DOCTYPE html&gt;↵&lt;html&gt;↵&lt;head&gt;↵&lt;/head&gt;↵&lt;body&gt;↵↵&lt;/body&gt;↵&lt;/html&gt;")
{
    // Editor empty
}
</code></pre>

<p>But it doesnt pick it up</p>

<h2>Code so far</h2>

<pre><code>function validateForm()
{
    var editorContent = tinyMCE.get('editor').getContent();
    if (editorContent == "" || editorContent == null)
    {
        // Add error message if not already present
        if (!$('#editor-error-message').length)
        {
            $('&lt;span id="editor-error-message"&gt;Editor empty&lt;/span&gt;').insertAfter($(tinyMCE.get('editor').getContainer()));
        }
    }
    else
    {
        // Remove error message
        if ($('#editor-error-message'))
            $('#editor-error-message').remove();

        document.getElementById('submit').submit();
    }
}
</code></pre>

<p>Has something changed in TinyMCE? What am i missing?</p>