ItSolutionStuff.com

How to Add CKEditor Required Field Validation in JQuery?

By Hardik Savani • June 2, 2023
jQuery

Hey Friends,

In this quick guide, we will teach you ckeditor required field validation. you will learn ckeditor validation not working. I’m going to show you about jquery validation engine ckeditor. I would like to show you ckeditor required field validation javascript. Here, Create a basic example of javascript validation for ckeditor textarea.

we can add required field validation easily using jquery if we have textbox, textarea, select box etc, but if we used ckeditor then it's not simple. In this example i give you how to add Ckeditor required field validation in javascript. we can do it using CKEDITOR.instances, so if you also require then you can use it.

Example:

<html lang="en">

<head>

<title>Jquery - ckeditor required field validation</title>

<script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>

<script src="//cdn.ckeditor.com/4.5.9/standard/ckeditor.js"></script>

</head>

<body>


<div class="container text-center">

<form>

<textarea name="editor"></textarea>

<button>Submit</button>

</form>

<script>

CKEDITOR.replace( 'editor' );

$("form").submit( function(e) {

var messageLength = CKEDITOR.instances['editor'].getData().replace(/<[^>]*>/gi, '').length;

if( !messageLength ) {

alert( 'Please enter a message' );

e.preventDefault();

}

});

</script>

</div>


</body>

</html>

I hope it can help you...

Tags: jQuery
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

šŸ“ŗ Subscribe on YouTube

We Are Recommending You

ā˜…

JQuery Remove All Numbers from String Example

Read Now →
ā˜…

How to Install and Use CKEditor in Angular?

Read Now →
ā˜…

How to Install and Use CKEditor in Laravel?

Read Now →
ā˜…

CKEditor Image Upload in Laravel Example

Read Now →
ā˜…

PHP JQuery Ajax Image Upload Example Tutorial

Read Now →
ā˜…

PHP CKEditor Custom File Upload Example

Read Now →
ā˜…

How to Get Gravatar Image from Email using JQuery?

Read Now →
ā˜…

JQuery Accordion using JQuery UI Example

Read Now →
ā˜…

PHP CKEditor with Image Upload using KCFinder Example

Read Now →
ā˜…

How to access PHP variables in JQuery?

Read Now →
ā˜…

How to Convert Line Breaks to br in jQuery ?

Read Now →
ā˜…

Laravel CKeditor 5 Image Upload Tutorial Example

Read Now →
ā˜…

How to Check Object is Empty or Not in JQuery?

Read Now →