codeMan codeMan - 2 months ago 25
jQuery Question

Validation in Bootstrap wysiwyg5 editor

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.

PS: I saw this question, but it was not very helpful.

Answer

I know the question is old, but maybe help somebody looking for this..

To make the JQuery Validation work with WysiHtml5, just set the plugin to not ignore hidden textareas:

$('#form').validate({
   ignore: ":hidden:not(textarea)",     
   rules: {     
       WysiHtmlField: "required"
   },
   submitHandler: function(form) { ... }
});