我想限制日期选择超过当前日期的7天..帮助我
<script>
var date = new Date();
var startdate = date.getFullYear().toString()+"-"+ date.getMonth.toString()+"-"+date.getDate()+1.toString();
var maxdate =date.getFullYear().toString()+"-"+ date.getMonth.toString()+"-"+date.getDate()+6.toString();
document.getElementById("demo").setAttribute("min",startDate);
document.getElementById("demo").setAttribute("max",maxdate);
</script>
答案 0 :(得分:0)
这里有很多方法可以做到这一点:
var date = new Date();
var startDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate();
maxDate = startDate.split('-').map(Number);
maxDate[2] += 7;
demo.max = maxDate.join('-');
demo.min = startDate;