<script src="$!webPath/resources/js/laydate/laydate.js"></script>
<script src="$!webPath/resources/js/ajaxfileupload.js"></script>
<script src="$!webPath/resources/js/jquery.zh.cn.js" charset="utf-8"></script>
<script>
jQuery(document).ready(function(){ jQuery.validator.methods.amount = function(e) {
var coupon_order_amount=jQuery("#coupon_order_amount").val();
var coupon_amount=jQuery("#coupon_amount").val();
if(parseInt(coupon_order_amount) > parseInt(coupon_amount)){
return true;
}else{
return false;
}
}; jQuery("#theForm").validate({
rules:{
coupon_description:{required:true},
coupon_name:{required:true},
coupon_begin_time:{required:true},
coupon_end_time:{required:true,endTime:"#coupon_begin_time"},
coupon_count:{digits:true},
coupon_amount:{required:true},
coupon_img:{accept:"图片格式只能为$!config.imageSuffix"},
coupon_order_amount:{required:true,digits:true}
},
messages:{
coupon_description:{required:"优惠券信息描述不能为空"},
coupon_name:{required:"优惠券名称不能为空"},
coupon_begin_time:{required:"开始时间不能为空"},
coupon_end_time:{required:"结束时间不能为空",endTime:"结束日期必须大于开始日期"},
coupon_count:{digits:"优惠券只能为整数"},
coupon_amount:{required:"优惠券金额不能为空"},
coupon_img:{accept:"图片格式只能为$!config.imageSuffix"},
coupon_order_amount:{required:"可使用订单金额不能为空",digits:"可使用订单金额只能为整数",min:"可使用订单金额必须大于优惠券金额",amount:"可使用订单金额必须大于优惠券金额"}
},
submitHandler:function(){
var params = jQuery("#theForm").serializeArray();
var formData= {};
jQuery.each(params, function(i, param){
formData[param.name] = param.value;
});
jQuery(".seller_save").attr("disabled","disabled");
jQuery.ajaxFileUpload({
url:'$!webPath/seller/coupon_save.htm',
dataType:'json',
fileElementId:['coupon_img'],
data:formData,
success:function(data){
var lin = ""+data.url;
if(data.ret==true){
showDialog("msg_info","",data.op_title,0,"succeed",3,function(arg){window.location.href=arg},lin,function(){
window.location.href = "$!webPath/seller/coupon.htm";
});
}
jQuery(".seller_save").removeAttr("disabled");
}
});
}
});
var isIE = ((navigator.userAgent.indexOf("compatible") > -1 && navigator.userAgent.indexOf("MSIE") > -1 && !isOpera)||navigator.userAgent.indexOf("Trident") > -1)?true:false;
jQuery.validator.methods.endTime = function(value, element, param) { debugger; var startDate = jQuery("#coupon_begin_time").val(); var date1=new Date(Date.parse(startDate)); var date2=new Date(Date.parse(value)); if(isIE){ date1 = new Date(Date.parse(startDate.replace("-", "/"))); date2 = new Date(Date.parse(value.replace("-", "/"))); } return date1 <= date2; };
});

具体间隔天数的比较

var isIE = ((navigator.userAgent.indexOf("compatible") > -1 && navigator.userAgent.indexOf("MSIE") > -1 && !isOpera)||navigator.userAgent.indexOf("Trident") > -1)?true:false;
function timeRule(cur){
if(parseInt(cur)<10){
cur = "0"+cur;
}
return cur
}
function curDate(){
var date = new Date(),
year = date.getFullYear(),
mouth = date.getMonth()+1,
datec = date.getDate(),
hour = date.getHours(),
minite = date.getMinutes(),
seconds = date.getSeconds(),
millsieconds = date.getMilliseconds(); mouth = timeRule(mouth);
datec = timeRule(datec);
hour = timeRule(hour);
minite = timeRule(minite);
seconds = timeRule(seconds); return (year+'-'+mouth+"-"+datec+" "+hour+":"+minite+":"+seconds)
} jQuery.each(jQuery('.coupon-card.active'),function(i,item){
var startTime = curDate(),
endTime = jQuery(item).find('.s-end-time').text(),
date1 = new Date(Date.parse(startTime)),
date2 = new Date(Date.parse(endTime));
if(isIE){
date1 = new Date(Date.parse(startTime.replace("-", "/")));
date2 = new Date(Date.parse(endTime.replace("-", "/")));
}
if(((date2-date1)/(1000*60*60*24))<3){
jQuery(item).removeClass('active').addClass('must-use');
};
})

  

  

javascript笔记——date以及datetime的比较的更多相关文章

  1. Java 和 Javascript 的 Date 与 .Net 的 DateTime 之间的相互转换

    Java 和 Javascript 的 Date 对象内部存放的是从1970年1月1日0点以来的毫秒值. .Net 的 DateTime 对象内部存放的是从0001年1月1日12点以来的tick值,1 ...

  2. [Effective JavaScript 笔记] 第5条:避免对混合类型使用==运算符

    “1.0e0”=={valueOf:function(){return true;}} 是值是多少? 这两个完全不同的值使用==运算符是相等的.为什么呢?请看<[Effective JavaSc ...

  3. [Effective JavaScript 笔记]第27条:使用闭包而不是字符串来封装代码

    函数是一种将代码作为数据结构存储的便利方式,代码之后可以被执行.这使得富有表现力的高阶函数抽象如map和forEach成为可能.它也是js异步I/O方法的核心.与此同时,也可以将代码表示为字符串的形式 ...

  4. [Effective JavaScript 笔记]第28条:不要信赖函数对象的toString方法

    js函数有一个非凡的特性,即将其源代码重现为字符串的能力. (function(x){ return x+1 }).toString();//"function (x){ return x+ ...

  5. python中date、datetime、string的相互转换

    import datetime import time string转datetime str = '2012-11-19' date_time = datetime.datetime.strptim ...

  6. javascript中Date对象的应用——简易日历的实现

    × 目录 [1]效果 [2]HTML [3]CSS[4]JS 前面的话 简易日历作为javascript中Date对象的常见应用,用途较广泛.本文将详细说明简易日历的实现思路 效果演示 HTML说明 ...

  7. JavaScript的Date对象

    整理了一些JavaScript时间的对象,如下所示: toLocaleString()得到当前的年月日和时间的字符串 toLocaleTimeString() 得到当前的时间字符串 toLocaleD ...

  8. Javascript日期与C# DateTime 转换

    DateTime的日期到了客户端为:"/Date(1346818058450+0800)/"; 转吧: var renderTime = function (dateTime) { ...

  9. [Effective JavaScript 笔记] 第4条:原始类型优于封闭对象

    js有5种原始值类型:布尔值.数字.字符串.null和undefined. 用typeof检测一下: typeof true; //"boolean" typeof 2; //&q ...

随机推荐

  1. [小技巧]設定Reporting Services 2008 發生報表管理員權限不足

    转载 http://www.dotblogs.com.tw/dorlis.tsao/archive/2011/01/17/20860.aspx 在自己Windows 7 professional的電腦 ...

  2. Codeforces Round #Pi (Div. 2) A. Lineland Mail 水题

    A. Lineland MailTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/probl ...

  3. HDU 4348 To the moon 可持久化线段树,有时间戳的区间更新,区间求和

    To the moonTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.a ...

  4. 在 C# 中加载自己编写的动态链接库

    一.发生的背景    在开发新项目中使用了新的语言开发 C# 和新的技术方案 WEB Service,但是在新项目中,一些旧的模块需要继续使用,一般是采用 C 或 C++ 或 Delphi 编写的,如 ...

  5. [OSG]如何用Shader得到物体的世界坐标

    来自:http://www.cnblogs.com/hesicong/archive/2008/05/27/1208312.html 最近群里面有个朋友问我关于如何得到OpenGL世界坐标的问题,当时 ...

  6. jsonp跨域原理解析

    前言: 跨域请求是前台开发中经常遇到的场景,但是由于浏览器同源策略,导致A域下普通的http请求没法加载B域下的数据,跨域问题由此产生.但是通过script标签的方式却可以加载非同域下的js,因此可以 ...

  7. Opacity多浏览器透明度兼容处理(转)

    用来设定元素透明度的 Opacity 是CSS 3里的一个属性.当然现在还只有少部分浏览器支持. 不过各个浏览器都有自己的私有属性来支持,其中包括老版本的Mozilla和Safari: IE: fil ...

  8. struts开发经验汇总

    笔者接触struts2之时,对于web开发甚至还没有概念,仅有的知识是如何利用HTML.CSS和简单的JS进行静态网页的编写.对于开发一个网站所必需的后台.数据库基本没有了解. 因此这篇博文,可以说不 ...

  9. Asp.Net 之 WebService部署到服务器后出现" The test form is only available for requests from the local machine "

    最近由于任务需要开发了一个WebService, 部署到服务器以后,出现上述问题,网上查找到如下解决方案: 问题原因: 从 NET Framework 1.1 起定义了一个名为 HttpPostLoc ...

  10. Windows 之 删除文件出现“该项目不在请确认该项目的位置”

    原理为通过 DOS 命令自建一个 .bat 批处理文件. 第一步,首先桌面新建TXT文档: 第二步,主要使用DEL 和 RD 命令,打开文档复制下面内容里面: DEL /F /A /Q \\?\%1 ...