I populate 2 dates 03-Mar-2015
and 03-Jun-2015
, if Last 3 months option is selected.I perform the below JavaScript validation to check for 90 days. But it shows validation error that the two dates selected are greater than 90 days. But my constraint is not allow users to select more than 3 months duration.
function DtTimeDiff(sender, args) {
var startDate = Date.parse(document.getElementById('ctl00$MainContent$FromYearTxt').value);
var endDate = Date.parse(document.getElementById('ctl00$MainContent$ToYearTxt').value);
var timeDiff = endDate - startDate;
daysDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
if (daysDiff > 90) {
args.IsValid = false;
}
else {
args.IsValid = true;
}
}
How to perform validation for 3 months having 91 days(Mar,Apr,May) and 92 days (Jul,Aug,Sep)? Constrain is not allow users to select more than 3 months duration.