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

How to limit the from to date range when all day event check box is not selected

1 Answer 75 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
administrator
Top achievements
Rank 1
administrator asked on 16 Jun 2015, 06:16 PM

Hi,

I'm developing a leave management application and I have 2 types of leaves. Full day leave and half day leave. I want to limit the from and to date time pickers to same day if the full day event check box is not clicked in the default popup that appears in the add event popup.

 Currently it shows 1 day difference in from and to date pickers when full day event check box is not clicked and user can select any day with any gap in from and to date pickers. 

 I've tried to do it but failed. Would be grate if someone can help me on doing this.

 Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 18 Jun 2015, 11:38 AM
Hello Indika,

You need to define custom validation rule and validate the "start" / "end" fields based on the "allDay" field value. This can be done by extending the build-in validation rules as follows:

//this code block should be added before the Scheduler initialization code
//it can be used for both the MVC wrapper and Kendo UI
(function($, kendo) {
  //Extending the Grid build in validator
  $.extend(true, kendo.ui.validator, {
    rules: {
      // Add custom validation rule to validate
      //description field
      description: function(input, params) {
         
        if (input.is("[name='description']")) {
          if (input.val() != undefined && input.val().length > 0) {
            return true;
          } else {
            return false;
          }
        }
        //check for the rule attribute
        return true;
      }
    },
    messages: { //custom rules messages
      description: function(input) {
        // return the message text
        return "Description field is required!";
      }
    }
  });
})(jQuery, kendo);

Regards,
Vladimir Iliev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Scheduler
Asked by
administrator
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or