Problem in Validating Start and End Time Periods


I need to validate the start and End periods while adding event.
i have the following things in code-behind

Scheduler.Config.xml_date = "%m/%d/%Y %H:%i" Scheduler.Config.details_on_create = True Scheduler.Config.details_on_dblclick = True Dim js As New List(Of String) js.Add("scheduler.attachEvent('onEventSave',function(id,data,is_new_event){" & _ "var isValid= validateMe(id,data,is_new_event); return isValid;})") Scheduler.BeforeInit = js

in my design view, i have the definition for validateMe

function validateMe(id, data, is_new_event) { if (!data.text || $.trim(data.text)=='') { alert("Subject can not be empty"); return false; } //alert(data.start_date); // alert(data.end_date); if (data.start_date > data.end_date) { alert("Start Date should be less than End date"); return false; } return true; }

this validation not working for start and end dates… when i put alert, its returning both as are same dates, even though i have selected a past date for end_date and future one for start_date…

Please guide what is wrong in here

Thanking you in advance!

you need to compare dates by values

if (data.start_date.getTime() > data.end_date.getTime()){ }


thanks for replying… but that didnt work.

i have used the same code u gave…

also as i mentioned, if i put an alert of start and end dates, it is returning end date and start date both are same… that is if i select 30 march 2012 as start_date, and 11 march 2012 as end_date, when in alert , it says start_date=30 march 2012, and end_date = 30 march 2012 instead of 11 march…

so the following condition is not returning true…

if (data.start_date.getTime() > data.end_date.getTime()){ alert("Start Date should be less than End date"); return false; }

please advice…Thanks for helping…

Scheduler has built-in validation of dates at the client side.
If end_date is less or equal to start_date, end_date will be automaticly set to
<start_date + DHXScheduler.Config.time_step>


thank u… i realized that the scheduler automatically validates and assigns correct possible
end_date…but my client is expecting validation…thats y…

thanks anyway…