<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"); } }); } }); function isIE(){ if(navigator.userAgent.indexOf("MSIE")!=-1) { return true } return 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; };});
时间: 2024-12-29 23:09:39