Reputation: 5758
I am using Bootstrap wysiwyg5 editor as a part of a form.
This text area happens to be a required field(should not be empty). I want to validate if the user has entered any value on to this field or not. I see that Bootstrap wysiwyg uses a Iframe to display the content. I tried to access the content of the iframe's body in jQuery by doing this:
$('.textarea.wysihtml5-editor').html()
but failed.
My question is: How do I check if the user has entered some text in this Bootstrap wysiwyg textarea. Please help me out.
Upvotes: 1
Views: 1338
Reputation:
wysiwyg editor does not works in bootstrap modal because it triggers before creating modal.. or something. so the best way to do it is triggering the modal before wysiwyg editor.
function showmymodal(){
$('#modal').modal('show');
$("#modal").html(' <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">modal header</h3></div>
<div class="modal-body">
<textarea id="textarea"></textarea>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</form>');
$('#textarea').wysihtml5({
"font-styles": true,
"emphasis": true,
"lists": true,
"html": false,
"link": true,
"image": true,
"color": true
});
}
you can check on Tutorial website
Upvotes: 1
Reputation: 572
Have you tried this question?
How to access the content of an iframe with jQuery?
The answer from the question referenced above:
$("#myiframe").contents().find("#myContent")
Edited to add my original answer:
$('.textarea.wysihtml5-editor').val()
Upvotes: 2