标签:
function getRewardDays(){
var bgAddTime = $(‘#addstartTime‘).datebox("getValue");
var edAddTime = $(‘#addendTime‘).datebox("getValue");
// 获取两个日期天数差
var bgDates = new Date(bgAddTime);
var edDates = new Date(edAddTime);
var dayss = edDates.getTime() - bgDates.getTime();
var rewardDayss= (parseInt(dayss / (1000 * 60 * 60 * 24)))
return rewardDayss;
}
function save(){
var signActivity=new Object();
if ($("#idHidden").val() != null && $("#idHidden").val() != "") {
signActivity.signActivityId = $("#idHidden").val();
}
var bgAddTime = $(‘#addstartTime‘).datebox("getValue");
var edAddTime = $(‘#addendTime‘).datebox("getValue");
// 获取两个日期天数差
var bgDate = new Date(bgAddTime);
var edDate = new Date(edAddTime);
var days = edDate.getTime() - bgDate.getTime();
var rewardDays= (parseInt(days / (1000 * 60 * 60 * 24)))
var result=getRewardDays();
$("#addrewardDays").val(result);
if($("#addstartTime").datebox("getValue")==""||$("#addstartTime").datebox("getValue")==null){
$.messager.alert("提示","开始时间不能为空","info");
return;
}
if ($("#addendTime").datebox("getValue") == null|| $("#addendTime").datebox("getValue") == "") {
$.messager.alert(‘提示‘, "结束时间不能为空", ‘info‘);
return;
}
if ($("#addstartTime").datebox("getValue") >= $("#addendTime").datebox("getValue")) {
$.messager.alert(‘提示‘, "开始时间不能大于结束时间", ‘info‘);
return;
}
if($("#addactivityIntroduction").val()==null || $("#addactivityIntroduction").val()==""){
$.messager.alert(‘提示‘, "请输入活动的内容介绍", ‘info‘);
return;
}
if($("#addrewardName").val()==null ||$("#addrewardName").val()==""){
$.messager.alert(‘提示‘, "请输入奖励积分名称", ‘info‘);
return;
}
if($("#addrewardContent").val()==null ||$("#addrewardContent").val()==""){
$.messager.alert(‘提示‘, "请输入奖励积分分值", ‘info‘);
return;
}
signActivity.signActivityId = $("#idHidden").val();
signActivity.startTime = $("#addstartTime").datebox("getValue");
signActivity.endTime = $("#addendTime").datebox("getValue");
signActivity.platform=$("#addplatform").combobox("getValue");
signActivity.activityIntroduction=$("#addactivityIntroduction").val();
signActivity.rewardType=$("#addrewardType").combobox("getValue");
//默认是开始减去结束时间
signActivity.rewardDays=rewardDays+1;
signActivity.rewardName=$("#addrewardName").val();
signActivity.rewardContent=$("#addrewardContent").val();
//默认签到规则
doAjax({
url:appPath+‘/page/signActivityAct/saveOrUpdate‘,
type:‘post‘,
data:signActivity,
success : function(data) {
if (data == "ok") {
$.messager.alert(‘提示‘, "保存成功", ‘info‘);
$(‘#opreateHtml‘).window(‘close‘);
doQuery();
} else {
$.messager.alert(‘提示‘, data, ‘info‘);
}
}
});
}
<tr>
<td class="queryTitle" width="100px">结束时间</td>
<td class="queryContent" ><input class="inputText easyui-datetimebox" type="text" id="addendTime" onChange="getRewardDays()"/></td>
</tr>
日期格式的插件是DatatimeBox,但是该插件没有事件方法,找到其依赖(即父类)databox,只有一个onselect事件,不满足需要,再找到databox的父类combox,找到onselect事件,满足需求,即:当文本域的值改变的时候触发。
标签:
原文地址:http://www.cnblogs.com/wangchuanfu/p/5844666.html