Here i have \"From Date\" and \"To Date\" with submit button. And i\'m using telerik radate control for this project. So, I couldn\'t add that telerik control.
Here Ever
You can set the month to a date in the past and compare with that:
var today = new Date(), // you can use only one Date, this is only for clarity
back = new Date();
back.setMonth( today.getMonth() - 13);
return fromDate > back;
Fixing the day as suggested by @mplungjan:
var months = 13;
if (back.getMonth() == (today.getMonth() - months % 12 + 12 + 1) % 12)
back.setDate(-1);
Updated fiddle: Use a clone of endDate
instead of today
to init back
, then compare with startDate
:
var back = new Date(endDate);
…
return startDate > back;
var toDate= urToDate;
var fromDate= urFromDate;
fromDate.setMonth(toDate.getMonth()+13);
if(fromDate>toDate)
{
//Do your work
}
else
{
//from date is older
}