How to check for empty editor content

3 posts, 0 answers
  1. Jon
    Jon avatar
    53 posts
    Member since:
    Oct 2013

    Posted 20 Jan Link to this post

    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. Jon
    Jon avatar
    53 posts
    Member since:
    Oct 2013

    Posted 20 Jan in reply to Jon Link to this post

    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() == ""

  3. Kendo UI is VS 2017 Ready
  4. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 21 Jan Link to this post

    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!
     
Back to Top