jQuery CKEditor Validation Example with demo

Today, We want to share with you jQuery CKEditor Validation.In this post we will show you Ckeditor required field validation example in Jquery, hear for Validate CKEditor Fields Using JQuery we will give you demo and example for implement.In this post, we will learn about ckeditor required field validation with an example.

jQuery CKEditor Validation

There are the Following The simple About jQuery CKEditor Validation Full Information With Example and source code.

As I will cover this Post with live Working example to develop Validate CKEditor Using jQuery Validate, so the some major files and Directory structures for this example is following below.

Required field validation ckedito

ckeditor cdn

First if all You include jQuery as well as ckeditor CDN in Your Project.

  • JQuery-2.2.4.js
  • JQuery.Validate.js
  • CKEditor.js

We have HTML Source code like –

I applied CKEditor on above textarea name as ckproduct_img –

SCRIPT FOR CKEDITOR

var obj  = { 
	stylesSet : [ 
	{name: 'Align Left', element: ['p','h1','h2','h3','h4','h5','h6','td','th','div','ul','ol','li','table','img'], attributes: {'class': 'text-left'}}, 
	contentsCss  : ['/assets/admin/css/custom.css'], 
	allowedContent:true, 
	removeButtons :  JustifyLeft
};
CKEDITOR.replace('ckproduct_img', obj); 

SCRIPT FOR jQuery VALIDATION

jQuery.validator.addMethod('ckrequired', function (value, element, params) { 
	var idname = jQuery(element).attr('id'); 
	var messageLength =  jQuery.trim ( CKEDITOR.instances[idname].getData() ); 
	return messageLength.length !== 0; 
}, "Image field is required"); 

Then write the validation rule for the text area as –

jQuery("#product_img").validate({ 
ignore: [], 
rules: { 
	ckproduct_img: { 
	ckrequired: true 
	} 
}, 
messages: {         
	ckproduct_img: { 
	ckrequired : "Please select an Any image required" 
	}
} 
});

Including a default text in CKEditor



    
        
        Ckeditor required field validation example in Jquery
        
    
    
	

ckeditor 4 Examples

how to use ckeditor in php

simple add or embed CKEditor in php page

BasePath = 'ckeditor/';
    $CKeditor->editor('editor1');
?>
Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about jQuery CKEditor Validation.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment