Validate CKEditor value is blank (empty) in ASP.Net MVC using jQuery

on Apr 21, 2022 06:15 AM


I have field which is binded using CK editor.

On submit click i want to show error incase the field is empty.

Currently it is not displaying validation message if empty.

I am developing mvc site.

Below is field.

<div class="document-editor">
    <div class="document-editor__toolbar"></div>
    <div class="document-editor__editable-container">
        <div class="document-editor__editable" name="Content">
@Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })


Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Apr 21, 2022 06:23 AM
on Jul 14, 2022 08:24 AM

You can use getData function to check the value is empty or not.

Check the sample code.


<html xmlns="">
    <link href="Script/css.css" rel="stylesheet" type="text/css" />
    <script src="Script/jquery.min.js" type="text/javascript"></script>
    <textarea name="editor" rows="2" cols="20" id="editor"></textarea>
    <input type="button" name="btnSave" value="Save" id="btnSave" />
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        $(function () {
            var editor = CKEDITOR.replace('editor');
            $("#btnSave").click(function () {
                if (editor.getData() == "") {
                    alert('CKEditor is Empty.');