Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo ui Multiselect validation

does anyone knows how to validate the Kendo UI Multiselect Widget with the Kendo UI validator?
I only want to check if the selections contains something or is empty.
The Multiselect should be required.

Thanks

like image 287
chris Avatar asked May 16 '13 14:05

chris


1 Answers

Given a multiselect defined as:

<select id="tags" multiple="multiple" name="tags" required data-required-msg="Select start time"></select>

and the following JavaScript for initializing it:

var multi = $("#tags").kendoMultiSelect({
    dataSource: {
        transport: {
            read: function (op) {
                var data = [
                    "Option1", "Option2", "Option3", "Option4", "Option5"
                ];
                op.success(data);
            }
        }
    }
}).data("kendoMultiSelect");

Add the following code for validating it:

// Get reference to the validator
var validator = $("#tags").kendoValidator().data("kendoValidator");

// Bind validation to blur
$("input", multi.wrapper).on("blur", function() {
    validator.validate();
});
like image 81
OnaBai Avatar answered Sep 28 '22 08:09

OnaBai