I'm working with TinyMCE. The problem is every time I try to post after fulfilling a set of conditions for title and body, I get the error message for minimal body chars. If I delete this condition it is posted successfully. If I remove the TinyMCE and use simple a textarea
it will again be posted successfully. What is wrong between TinyMCE and if
-condition for body.
<script type="text/javascript">
$(document).ready(function() {
$('#submit').click(function() {
var title = $('#title').val();
var body = $('#editor').val();
if (title == '') {
$('#erd').html('Please enter a title first');
return false;
}
if (body.length < 500) {
$('#erd').html('Body must not be less than 500 characters');
return false;
}
});
});
</script>
<legend>Title:</legend>
<input type="text" id="title" name="title" />
<br />
<br />
<legend>Body:</legend>
<textarea name="body" id="editor" style="border-radius:5px;"></textarea>
<br />
<script type="text/javascript" src="./js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea#editor",
width: "640px",
height: "300px",
browser_spellcheck: true,
plugins: [
"advlist autolink textpattern wordcount lists link image charmap preview",
"searchreplace code fullscreen imagetools jbimages save",
"media table contextmenu paste"
],
toolbar: "insertfile undo redo | styleselect | bold italic | underline | strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent| blockquote | link jbimages | media",
relative_urls: false,
});
</script>