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

Validation function on one column is validating also on all others

1 Answer 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
CS
Top achievements
Rank 2
CS asked on 18 Jun 2014, 02:36 PM
I added a validation function to a field, but also all the other fields with validation: true get validated with this function which is totally wrong. Is that an intended behaviour?

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 20 Jun 2014, 07:15 AM
Hi Stefan,

Basically current behavior is expected - in your validation function you should check if the current input element is the desired before executing the validation code. Please check the example below:

ProductName: {
    validation: {
        required: true,
        productnamevalidation: function (input) {
            if (input.is("[name='ProductName']") && input.val() != "") {
                input.attr("data-productnamevalidation-msg", "Product Name should start with capital letter");
                return /^[A-Z]/.test(input.val());
            }
 
            return true;
        }
    }
},

Also you can check the following demo of the grid with custom validation:
Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
CS
Top achievements
Rank 2
Answers by
Vladimir Iliev
Telerik team
Share this question
or