Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

TinyMCE textarea validation

7:19 pm on Nov 17, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:June 18, 2010
posts: 170
votes: 1

Hello everyone,

I came across the need of using a rich text editor, I ended up choosing TinyMCE, it works real nice but no matter how much I've tried I can't get to validate the data prior to submitting it.

All I want is to make sure the textarea (which I believe is no longer a textarea since TinyMCE converts it into some other elements) is not empty, I have tried several examples on their forum with no luck so I'm trying my luck here.

Has anyone dealt with this issue? Thanks.
12:26 pm on Nov 27, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 30, 2007
votes: 0

You could use the getContent and check if the content is empty.

So you hook the submit button and check if there is any content before allowing or setting the form action.
7:07 pm on Jan 2, 2012 (gmt 0)


WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
votes: 3

And if you have more than one instance of the editor running you may want to use the triggerSave() method:


If you want to focus on any element after realizing it is empty you can use the execCommand:


pseudocode example:
if (your textarea has an error) { 
tinyMCE.execCommand('mceFocus', false, 'textareaID');
return false;

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members