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

Disable validation DropDownListFor when no items

1 Answer 1020 Views
Validation
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 2
Sebastian asked on 14 Jun 2013, 02:16 PM
Hello,

I have 9 DropDownListFor that cascades from other DropDownList. I need to disable validation for DropDownLists that has no items. How to do it ?

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 18 Jun 2013, 09:15 AM
Hello Sebastian,

Kendo Validator works on the basis of HTML validation attributes. In order to disable/remove a given validation rule, you can remove the corresponding attribute from DropDownList element.

Please hook up to the dataBound event of the widget and remove the validation attributes if there is no data in the dataSource. For example:
onDataBound: function(e) {
    if(this.dataSource.data().length == 0) {
        this.element.removeAttr("required");
    }
}

I hope this will help.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Validation
Asked by
Sebastian
Top achievements
Rank 2
Answers by
Alexander Valchev
Telerik team
Share this question
or