How to add CKEditor required field validation in Jquery
In these tutorials, we can include required field approval effectively utilizing jquery on the off chance. we have a textbox, radio, text region, select box, Image, more. I give you how to include Ckeditor required field approval in Jquery. we can do it utilizing CKEDITOR.
Also Read : How to use multiple textarea with CKEditor 5
how-to-add-ckeditor-required-field-validation-in-Jquery.html
<html lang="en">
<head>
<title>How to add ckeditor required field validation in Jquery</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>
<script src="https://cdn.ckeditor.com/ckeditor5/1.0.0-alpha.2/classic/ckeditor.js"></script>
</head>
<body>
<div class="container text-center">
<h2>How to add ckeditor required field validation in Jquery</h2>
<form id="ckeditorForm" method="post">
<textarea name="editor" class="ck_editor_txt" id="ck_editor_txt"></textarea><br>
<button>Submit</button>
</form>
<script>
var allEditors = document.querySelector('.ck_editor_txt');
ClassicEditor.create(allEditors);
$("#ckeditorForm").submit(function(e) {
var content = $('.ck_editor_txt').val();
html = $(content).text();
if ($.trim(html) == '') {
alert("Please enter message");
e.preventDefault();
} else {
alert("Success");
}
});
</script>
</div>
</body>
</html>