Adding jquery validation to kendo ui elements

I looked through a lot of posts on this subject and worked on the fact that it checks my fields when I add the following.

$.validator.setDefaults({
    ignore: []
});

The part I'm still missing is adding a class input-validation-errorto notify the user. It works great for my other input elements (not kendo). I tried to add the class manually in $.validator.setDefaults, but nothing works.

Is there any example somewhere or did someone get it to work?

I'm not sure I'm doing it right, but here is what I tried to add manually.

$.validator.setDefaults({
    ignore: [],
    errorClass: "input-validation-error",
    errorElement: "input",
    highlight: function (element, errorClass) {
        $(element).addClass(errorClass)
    },
    unhighlight: function (element, errorClass) {
        $(element).removeClass(errorClass)
    }
});
+4
source share
1 answer

. , input. - :

$.validator.setDefaults({
    ignore: [],
    highlight: function (element, errorClass) {
        element = $(element);
        if (element.parent().hasClass("k-widget")) {
            element.parent().addClass('input-validation-error');
        } else {
            element.addClass('input-validation-error')
        }
    },
    unhighlight: function (element, errorClass) {
        element = $(element);
        if (element.parent().hasClass("k-widget")) {
            element.parent().removeClass('input-validation-error');
        } else {
            element.removeClass('input-validation-error')
        }
    }
});

, , , , , , . , , .

+7

Source: https://habr.com/ru/post/1527204/


All Articles