SO-20162435

by Tushar Gupta

JavaScript

Date.prototype.addDays = function (days) {
    this.setDate(this.getDate() + days);
    return this;
};

function val_date(input) {
    var inputDate = new Date(input);
    var dateWeek = new Date().addDays(7);
    console.log(inputDate, dateWeek);
    if (inputDate < dateWeek) {
        // The selected time is less than 7 days from now
        return false;
    } else {
        // The selected time is more than 7 days from now
        return true;
    }
}
alert(val_date('11/21/2013'));