我想检查我在输入字段(html)中输入的日期和时间,以便这些条目不早于当前日期之前的6个月。时间。我们如何验证这种情况?
答案 0 :(得分:5)
尝试使用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");
}
}