Validation incorrectly showing up when initial value in multiselect

3 posts, 1 answers
  1. Brent Sheppard
    Brent Sheppard avatar
    14 posts
    Member since:
    Oct 2018

    Posted 18 Oct 2019 Link to this post

    When using a MultiSelectFor, I am having a problem with kendo validator if there is already a value in the model for that multiselect.


    For example:

    Below is the code for the MultiSelectFor. On my form I am checking to see if a property of a model exists, if so I am adding the validator with the message "Required" to it. It is my understanding that this should only occur if the multiselect is empty. Attached is a picture of the required validator showing when there is a selection in the multiselect. The problem is when there is an initial value on the first load, after that it works as intended where it is removed when a value is selected and is shown when there is no value.

    In the attachment you will see that it is only this multiselect that has a problem. everything else works fine with an initial value.

    How do I go about making sure that if there is an initial value that the validator is not shown? Is there an event that fires after the value is populated so that I can run a validation function to clear out the validation?

    01.validateForm: function() {
    02.    var validator = $('#' + this.formName).kendoValidator({
    03.        messages: {
    04.            required: "Required"
    05.        }
    06.    }).data("kendoValidator");
    08.    if (validator != null)
    09.        return validator.validate();
    10.    else return null;


    @(Html.Kendo().MultiSelectFor(m => m.SelectedResources).DataTextField("Text").DataValueField("Value").Placeholder("No Resources Selected").DataSource(source => { source.Read("ReadActiveUsers", "_System");}))
  2. Answer
    Aleksandar avatar
    112 posts

    Posted 22 Oct 2019 Link to this post

    Hello Brent,

    The observed issue occurs because the validation for the MultiSelect is triggered before data is bound to the widget. 

    You could resolve the issue by calling the validation function in the DataBound event handler for the MultiSelect. This event is fired when the widget is bound to data from its data source:

    function onDataBound(e) {

    Give the above suggestion a try and let me know if any of these approaches work for you. In case of further questions please get back to me.

    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Brent Sheppard
    Brent Sheppard avatar
    14 posts
    Member since:
    Oct 2018

    Posted 22 Oct 2019 in reply to Aleksandar Link to this post


    The above solution worked. Thank you!

Back to Top