The Date object is returned by datePicker .
Your date comparison method is valid - from W3schools :
var myDate=new Date(); myDate.setFullYear(2010,0,14); var today = new Date(); if (myDate>today) { alert("Today is before 14th January 2010"); }
Are you getting the value in oDate from this line?
oDate = $("#oDP").datepicker("getDate");
Your comparison method seems valid - so I wonder if datePicker successfully pull a value from #oDP ?
Edit - oDate confirmed that it contains a valid date. This may be a very stupid question, but have you confirmed that Date contains a valid date? I am wondering if there could be a problem with naming it in the same way as the Date keyword ( Javascript keywords and reserved words ). Perhaps try renaming it to tDate or the like in your function to be twice as clear that this is not a problem.
source share