jQuery Validate CKEditor value is blank or not

Today, We want to share with you jQuery Validate CKEditor value is blank or not.In this post we will show you Validate CKEditor Using jQuery Validate, hear for How to check whether CKEDITOR value is blank or not we will give you demo and example for implement.In this post, we will learn about ckeditor required field validation using jquery with an example.

jQuery Validate CKEditor value is blank or not

There are the Following The simple About jQuery Validate CKEditor value is blank or not Full Information With Example and source code.

As I will cover this Post with live Working example to develop jquery validation for ckeditor textarea, so the CKEditor jQuery Validate for this example is following below.

<html>
   <head>
      <title>jquery check whether CKEDITOR value is blank or not</title>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://openconcept.ca/sites/all/libraries/ckeditor/ckeditor.js"></script>
      <script type="text/javascript"></script>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <script type="text/javascript">
         function validate(obj)
         {
			 $(".editorError").remove();
			 if(validateCKEDITORforBlank($.trim(CKEDITOR.instances.smart_ck_editor.getData().replace(/<[^>]*>|\s/g, '')))){
			 $("#smart_ck_editor").parent().append("<div class='editorError' id='editorError' style='color:red;'>Please Enter Describe your Contents here in details</div>");
			 CKEDITOR.instances.smart_ck_editor.setData("");
			 }
			 else
			 {
				 $("#smart_ck_editor").parent().append("<div class='editorError' id='editorError' style='color:green;'></div>");
				 document.getElementById("editorError").innerHTML ="Your Data Content Text:"+CKEDITOR.instances.smart_ck_editor.getData();
			 }
         }
         function validateCKEDITORforBlank(field)
         {
			 var allArrayData = new Array();
			 allArrayData = field.split(" ");
			 var editorFlag = 0;
			 for(var i=0;i<allArrayData.length;i++)
			 {
				 if(allArrayData[i] == '' || allArrayData[i] == "")
				 {
					continue;
				 }
				 else
				 {
				 editorFlag = 1;
					break;
				 }
			 }
			 
			 if(editorFlag == 0)
			 {
			 return true;
			 }
			 else
			 {
			 return false;
			 }
         }
      </script>
   </head>
   <body>

<h3>How to check whether CKEDITOR value is blank or not</h3>

                  <textarea  id="smart_ck_editor" name="smart_ck_editor"></textarea>
                  <script type="text/javascript">
                     CKEDITOR.replace( 'smart_ck_editor',
                     {
						fullPage : false,
						height: '100px',
						width: '600px',
						uiColor : '#f5f5f5',
						toolbarLocation : 'top'
                     });
                  </script>
				  <br/>
<input name="cksubmit" type="button" id="cksubmit" value="CKEDITOR Check" onclick="return validate(this)"/></td>
<a href="https://www.pakainfo.com/" target="_blank" alt="pakainfo" title="pakainfo">Free Download Example - Pakainfo.com</a>
   </body>
</html>

Note : jquery CKEDITOR takes simple 2 or more empty white spaces as & nbsp,Then we are using simple Javascript trim() function will not any data content treat field as empty check even though some white spaces are truely equal to all the blank.Same is some time problem with data enter, or press tab also,In therfor case We can use simple above jquery function.

Read Also:  php try catch Block Exception Handling
Angular 6 CRUD Operations Application Tutorials

Read :

Related Search: ckeditor empty content, ckeditor required field validation jquery, ckeditor required field validation javascript, jquery validation for ckeditor textarea, ckeditor textarea required, ckeditor post data empty, jquery validate textarea not empty, get ckeditor value, Check if CKEditor is empty, Validate CKEditor Using jQuery Validate, Validate ckeditor using Jquery form validation

Read Also:  Ckeditor required field validation using Jquery

Summary

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

I hope you get an idea about jQuery Validate CKEditor value is blank or not.
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.