Validate Data

Is it possible to validate an event duration. In my application it must be no longer than 36 hours.

I tried this, but it does not work:

dhx.dp($$(“scheduler”)).attachEvent(“onEventSave”, function(id, data) {
// in milliseconds
var duration = Math.abs(data.end_date - data.start_date);
// in hours
duration = duration / (1000 * 60 * 60);
if (duration > 36) {
alert(‘An event cannot be longer than 36 hours.’);
return false;
}
return true;
});

You can set validation rule:

scheduler.config.form_rules.end_date = function(value,data){ var duration = data.end_date - data.start_date; duration = duration / (1000 * 60 * 60); if(duration>36){ dhx.alert('An event cannot be longer than 36 hours.') } return duration>0&&duration<36; } dhx.ready(function(){ dhx.ui({ ... }); });

Thanks! It works great!!