I’m trying to validate a textarea so a user can’t add a new empty message via tinyMCE textarea.
But it just don’t seems to work.
What am i doing wrong ?
JS:
var msg = $("#msg");
if(msg.val() == ''){
$("#msg_error").html("* Can't add an empty message");
}
Textarea
<textarea rows="5" cols="35" id="msg"></textarea>
The textarea in TinyMCE is not always purely empty, althuogh you see nothing, TinyMCE automatically adds html to the textarea. What this means is the textarea will contain html code like
<p> </p>. What you must do is use php’sstrip_tagsfunction to remove html and test for emptiness afterward. Goodluck.This would mean using ajax requests to check the data every now and then.