如何在js中排除周六周日计算天数

来源:百度知道 编辑:UC知道 时间:2024/06/22 06:32:23
首先在输入框初始化当前日期
当改变日期超过当前日期三个工作日(排除周六周日)给出提示!

<html>
<script>
function test(){
var test = document.getElementById("test");
var changeDate = test.value.split("-");

if(new Date().getDay()==3||new Date().getDay()==6){

if(changeDate[changeDate.length-1]-new Date().getDate()>4){
alert("提示信息");
return;
}
}
if(new Date().getDay()==5||new Date().getDay()==4){
if(changeDate[changeDate.length-1]-new Date().getDate()>5){
alert("提示信息");
return;
}
}
if(changeDate[changeDate.length-1]-new Date().getDate()>3){
alert("提示信息");
}
}
</script>
<body>
<input type="text" id="test" onchange="test()" /><!--输入的日期格式为2008-12-11-->
</body>

</html>