I have a requirement where i need to find the date entered in the textfield should not be less than currentdate and future date should not exceed exactly date after 1 year from the eentered date.I have coded for former one but i later requirement i could not do it. I have posted code for checking less than current date here. Please let me know for checking if the date entered exceed the date after 1 year.
var currentDate = new Date();
var nextDate = new Date();
function checkLessThanCurrentDate() {
//var dateEntered = arguments[0]; -->Will have date that come form textfield
var day = dateEntered.split("/")[0];
var month = dateEntered.split("/")[1];
var year = dateEntered.split("/")[2];
//--->Logic for chekcing date less than current date
if ((year < currentDate.getFullYear() || (month - 1 < currentDate.getMonth() &&
year <= currentDate.getFullYear()) || ((day < currentDate.getDate()) && (month -
1 <= currentDate.getMonth()) &&
(year <= currentDate.getFullYear())))) {
return true;
}
else {
return false;
}
}
Here's how to get the date one year from now: