检查最多 6 个月前的 DateTime 验证

Check Validation for DateTime upto 6 month past

我想检查我在输入字段 (html) 中输入的日期和时间,以便这些条目不早于当前日期和时间之前的 6 个月。我们将如何验证此条件?

试试这个,javascript

中的日期验证函数
function dateValidation() {
        var b = new Date("2014/01/22"); //your input date here

        var d = new Date(); // today date
        d.setMonth(d.getMonth() - 6);  //subtract 6 month from current date 

        if (b > d) {
            alert("date is less than 6 month");
        } else {
            alert("date is older than 6 month");
        }
    }