Kendo-Grid column field validation

六眼飞鱼酱① 提交于 2019-12-05 09:52:37

There isn't really any error in your code, but more like an error in Kendo Grid's validation design. Even though you specify the validation function only in the title field, it will run the validation globally for any input field that you edit.

In validateTitle you need to filter which input you want the validating function to run on. Something like this:

if (input.is("[name='title']") && input.val().length > 5) {
    input.attr("data-validateTitle-msg", "Max length exceeded 5 characters only");
    return false;
}

If you need a live working demo, you can always refer to Telerik's online demos that are editable, very handy for playing around with things. Here's the demo for custom validation where they similarly have to filter the input for the field name.

Rajakrishna

you want simply required field validation means just add your view model property attributes

[Required(ErrorMessage ="CountryCode is Mandatory")]
        public virtual string CountryCode
        {
            get;
            set;
        }

We can easily set the maximum length using this code,It will not allow user to enter more characters than the specified one

  model: {
                    id: "CLASSID",
                    fields: {
                        CLASSID: { type: "number" },
                        CLSNAME: { type: "string" },
                        CLSFLAG: {
                            type: "string", validation: {
                                required: true,maxlength:"3"
                            }
                        },
                        CLSSTATUS: { type: "boolean" }
                    }
                }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!