所以基本上我需要在子表单上创建验证以控制用户在扩展请求中提交回溯日期。我使用了自定义对象验证,但显示原始保存、保存和关闭以及自定义对象保存、保存和关闭存在问题。
自定义对象验证正在工作,但显示原始保存、保存和关闭是一个主要问题。
请在下面找到代码。
<script type="text/javascript">
//Define date field ids
var dateOccurredFldId = 22418;
// For todays date;
Date.prototype.today = function () {
return (((this.getMonth()+1) < 10)?"0":"") + (this.getMonth()+1) +"/"+ ((this.getDate() < 10)?"0":"") + this.getDate() + "/" + this.getFullYear();
}
// For the time now
Date.prototype.timeNow = function () {
return ((this.getHours() < 10)?"0":"") + this.getHours() +":"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes() +":"+ ((this.getSeconds() < 10)?"0":"") + this.getSeconds();
}
Sys.Application.add_load(function() {
// Hijack Save and Close Button
$('#master_btnSave').clone().attr('id', 'master_customBtnSave').insertBefore('#master_btnApply');
$('#master_btnSave').hide();
$('#master_customBtnSave').unbind('click').prop("onclick", null).click(function(){ DateCheck('save');return false;});
// Hijack Save Button
$('#master_btnApply').clone().attr('id', 'master_customBtnApply').insertBefore('#master_btnApply');
$('#master_btnApply').hide();
$('#master_customBtnApply').unbind('click').prop("onclick", null).click(function(){ DateCheck('apply');return false;});
});
function DateCheck(type) {
//Get Date Field Values
var dateOccurred = new Date(String($CM.getFieldValue(dateOccurredFldId, false)));
var currentDate = new Date();
var dateTime = currentDate.today() + ' '+ currentDate.timeNow();
var currentDateTime = new Date(dateTime);
//Set Alert Box Title
var title = 'Warning';
if(dateOccurred) {
if(dateOccurred <= currentDate) {
WarningAlert('The <b>Entension Date</b> cannot be lesser than the <b> Current Date Created</b>','',title);
return false;
} else {
SaveApply(type)
}
} else {
SaveApply(type)
}
}
function SaveApply(type) {
if (type == 'save') {
$('#master_btnSave').click();
} else if (type == 'apply') {
$('#master_btnApply').click();
}
}
</script>