This is a migrated thread and some comments may be shown as answers.

How to check for empty editor content

2 Answers 1094 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 20 Jan 2016, 09:52 AM

I have a basic editor that I need to check for content. If empty I will generate error. My code to check for empty is:

    var dropdownlist = $("#addNew_dTeam").data("kendoDropDownList");
        if (dropdownlist.value() == "") {
            validFlag = false;
            errorMsg = "<li>Select Team</li>"
        }

        dropdownlist = $("#addNew_dType").data("kendoDropDownList");
        if (dropdownlist.value() == "") {
            validFlag = false;
            errorMsg += "<li>Select Entry Type</li>"
        }

        var multiSelect = $("#msServers").data("kendoMultiSelect");
        if (multiSelect.value() == "") {
            validFlag = false;
            errorMsg += "<li>Add at least one Server or select N/A</li>"
        }

        var editor = $("#diaryComments").data("kendoEditor");
        if (editor.value() == "") {
            validFlag = false;
            errorMsg += "<li>A comment is mandatory</li>"
        }

2 Answers, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 20 Jan 2016, 09:56 AM

Ooops hit enter and the question posted....

As you can see I'm checking a couple of dropdowns, a multiselect and an editor. The dropdowns and the multiselect correctly flag an error. The editor although I have no text is not being caught with editor.value() == ""

0
Alex Gyoshev
Telerik team
answered on 21 Jan 2016, 10:06 AM

Hello Jon,

The editor content may be empty, but still contain blank paragraph tags. You may need to account for that in the validation logic.

Zooming out of the issue, consider using the Kendo Validator instead of developing your own validation logic.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Editor
Asked by
Jon
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or