I am using jQuery Form Validator library for my validation and its working fine as per my expectations.
Now I have integrated WYSIWYG Editor called as CKeditor 4.x and I want to make required
validation. But its not working for me. Here is what I have done so far.
<textarea name="description" id="description" rows="10" cols="80" data-validation="required" data-validation-error-msg-required="Please Enter Blog Title." ></textarea>
<script src="//cdn.ckeditor.com/4.11.4/standard/ckeditor.js"></script>
<script>
CKEDITOR.replace( 'description' );
$.validate({
ignore: [],
form: '#admin-blog-form',
inputParentClassOnError: 'admin-form-error',
scrollToTopOnError: false,
debug: false,
rules: {
description: {
required: function () {
CKEDITOR.instances.description.updateElement();
},
minlength: 10
}
},
messages:
{
description: {
required: "Please enter Text",
minlength: "Please enter 10 characters"
}
}
});
</script>
As you can see I have a form id called as admin-blog-form
and my CKeditor id is description
.
I am trying to use rules
variable by following jquery-validation-not-working-with-ckeditor answer but its not working for me using this library.
I have also tried to follow documentation and trying to write custom-validators using below code.
$.formUtils.addValidator({
name: 'requiredCKEditor',
validatorFunction: function (value, $el, config, language, $form) {
return false;
},
errorMessage: 'You have to answer with an even number',
});
<textarea name="description" id="description" rows="10" cols="80" data-validation="requiredCKEditor" ></textarea>
But this also is not working for me. I have read libary's other documentation pages but nothing helped me to integrate this.
Can someone guide me how can I achieve this ?