Home · Latest · Trends  /  HTML, XML
1

How to check TinyMCE textarea not empty jQuery

rated 1 times [  1] [ 0]  / comments: 1 / hits: 1792  / 2 years ago, sun, jun 25, 2017, 15:25:07
TinyMCE editor is empty or not + minimum characters
<form action="index.php" enctype="multipart/form-data" method="post">
<div id="infoMessage" style="display:none;">Info Text</div>
<div>Description</div>
<div><textarea name="summary"></textarea></div>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tinymce/tinymce.min.js"></script>
<script>
tinymce.init({
selector: 'textarea',
height: 350,
menubar: false,
plugins: [
'advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table contextmenu paste code'
],
toolbar: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image'
});
</script>
<script>
$(document).ready(function(){
$('#submit').click(function() {
if(tinyMCE.get('summary').getContent().length < 150){
$(".mce-panel").css( "background-color", "#ffe3bb" );
$("#infoMessage").show("fast");
return false;
}else{
$(".mce-panel").css( "background-color", "#acd2b8" );
$("#infoMessage").hide("fast");
}
});
});
</script>
<input type="submit" name="query" id="submit" value="Submit" />
</form>
More From » HTML, XML
 

Comments

3
In v 4.7.1 tinymce.get should be by id
Code:
<textarea id="editor" class="editor" name="whatever"></textarea>

<script>
$(document).ready(function(){
$('#submit').click(function() {
if(tinymce.get('editor').getContent().length < 10){
alert(tinymce.get('editor').getContent().length);
$(".mce-container-body").css( "background-color", "#ffe3bb" );
$("#infoMessage").show("fast");
return false;
}else{
$(".mce-container-body").css( "background-color", "#acd2b8" );
$("#infoMessage").hide("fast");
}
});
});
</script>

<input type="submit" id="submit" class="button" value="Go" name="query">
[#6] Sunday, October 29, 2017, 16:25:05
 
Nica Radi
commented 2 years ago
Only authorized users can post. Please sign in first, or register a free account
 
Share
Snippets
Image align in bootstrap 4
2 years ago, thu, jun 22, 2017
Alternating row colors in smarty
2 years ago, sat, jun 24, 2017
Sponsor
Posted
Jorge

Jorge

Member since Jun 22, 2017
Total Code Snippets: 3
Total Comments: 0
Location: n/a
Following
User not following anyone yet.