`
朱嘉华
  • 浏览: 233745 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

js 控制试用期

阅读更多
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>有效期控制</title>
<script>
// 获取当前时间 验证时间yyyy—MM-dd
function getNowFormatDate()
{
   var day = new Date();

   var Year = 0;
   var Month = 0;
   var Day = 0;
   var CurrentDate = "";
   //初始化时间  
   Year    = day.getFullYear();
   Month    = day.getMonth()+1;
   Day      = day.getDate();
  
   CurrentDate += Year + "-";
  
   if (Month >= 10 )
   {
    CurrentDate += Month + "-";
   }
   else
   {
    CurrentDate += "0" + Month + "-";
   }
   if (Day >= 10 )
   {
    CurrentDate += Day ;
   }
   else
   {
    CurrentDate += "0" + Day ;
   }
   return CurrentDate;
}
// 比较当前日期和设定的时间
function checkEndDate( edate ) {
var today = getNowFormatDate();
var startDate = new Date(today.replace("-",",")).getTime() ;
var endDate = new Date(edate.replace("-",",")).getTime() ;

if( startDate >= endDate )

   return false;
}
return true;
}
function check(){
     var endDate='2009-12-28';
if(!checkEndDate(endDate)){
alert("您的软件试用时间已经到期,请联系供应商!!!")
window.close();
return false;
}
}
</script>
</head>

<body onload="check();">
    可以用了!
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics