1
用我目前的代碼,我能夠做一年的經驗,如何檢查重疊日期的經驗。例如,如果用戶在用戶選擇19/3/2003 - 18/6/2016之後單擊克隆的div中的添加更多按鈕,則用戶從原始div中選擇19/5/2005 - 18/6/2015。它應該說一個警告消息。jquery UI日期選擇器克隆重疊年份如何計算
這裏是jQuery代碼
/* select exp date ends here*/
/* dates starts here*/
/*addmore functionalities starts here*/
/*dynamic row for Education Table starts here*/
var count=0;
$(document).on("click", ".edu_add_button", function() {
var $clone = $('.cloned-row1:eq(0)').clone(true,true);
//alert("Clone number" + clone);
$clone.find('[id]').each(function(){this.id+='someotherpart'});
$clone.find('.btn_more').after("<input type='button' class='btn_less1 edu_btnle' id='buttonless'/>")
$clone.attr('id', "added"+(++count));
$clone.find(".school_Name").attr('disabled', true).val('');
$clone.find(".degree_Description").attr('disabled', true).val('');
$clone.find("input.deg_date")
.removeClass('hasDatepicker')
.removeData('datepicker')
.unbind()
.datepicker({
dateFormat: "mm-dd-yy",
changeMonth: true,
yearRange: "-100:+0",
changeYear: true,
maxDate: new Date(),
showButtonPanel: false,
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 99999999999999);
}, 0);
}
});
$clone.find("input.trans_date")
.removeClass('hasDatepicker')
.removeData('datepicker')
.unbind()
.datepicker({
dateFormat: "mm-dd-yy",
changeMonth: true,
yearRange: "-100:+0",
changeYear: true,
maxDate: new Date(),
showButtonPanel: false,
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 99999999999999);
}, 0);
}
});
$(this).parents('.educat_info').after($clone);
});
$(document).on('click', ".btn_less1", function(){
var len = $('.cloned-row1').length;
if(len>1){
$(this).closest(".btn_less1").parent().parent().parent().remove();
}
});
/*dynamic row for Education Table ends here*/
/*dynamic row for Test Score Table starts here*/
var count=0;
$(document).on("click", ".test_add_button", function() {
var $clone = $('.cloned-row2:eq(0)').clone(true,true);
$clone.find('[id]').each(function(){this.id+='someotherpart'});
$clone.find('.btn_more').after("<input type='button' class='btn_less1 selbtnless' id='buttonless'/>")
$clone.attr('id', "added"+(++count));
/*$clone.find(".school_Name").attr('disabled', true).val('');
$clone.find(".degree_Description").attr('disabled', true).val('');*/
$clone.find("input.txt_date")
.removeClass('hasDatepicker')
.removeData('datepicker')
.unbind()
.datepicker({
dateFormat: "mm-dd-yy",
changeMonth: true,
yearRange: "-100:+0",
changeYear: true,
maxDate: new Date(),
showButtonPanel: false,
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 99999999999999);
}, 0);
}
});
$(this).parents('.sel_text').after($clone);
});
$(document).on('click', ".btn_less1", function(){
var len = $('.cloned-row2').length;
if(len>1){
$(this).closest(".btn_less1").parent().parent().parent().remove();
}
});
/*dynamic row for Test Score Table ends here*/
/*dynamic row for Work Experience Table starts here*/
var count=0;
$(document).on("click", ".exp_add_button", function() {
var $clone = $('.cloned-row3:eq(0)').clone(true,true);
$clone.find('[id]').each(function(){this.id+='someotherpart'});
$clone.find('.btn_more').after("<input type='button' class='btn_less1 selbtnless' id='buttonless'/>")
$clone.attr('id', "added"+(++count));
$clone.find(".startDate").val('');
$clone.find(".endDate").val('');
/*$clone.find(".degree_Description").attr('disabled', true).val('');*/
$clone.find("input.startDate")
.removeClass('hasDatepicker')
.removeData('datepicker')
.unbind()
.datepicker({
dateFormat: "mm-dd-yy",
changeMonth: true,
yearRange: "-100:+0",
changeYear: true,
maxDate: new Date(),
showButtonPanel: false,
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 99999999999999);
}, 0);
}
});
$clone.find("input.endDate")
.removeClass('hasDatepicker')
.removeData('datepicker')
.unbind()
.datepicker({
dateFormat: "mm-dd-yy",
changeMonth: true,
yearRange: "-100:+0",
changeYear: true,
maxDate: new Date(),
showButtonPanel: false,
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 99999999999999);
}, 0);
}
});
$(this).parents('.wrk_exp').after($clone);
});
這裏是小提琴Link
請請建議我。
感謝&問候 馬哈德
感謝您的幫助,但我在計算加油吧 – Mahadevan
壓片也沒有發生:( –
更長時間後我沒有得到在上盒的任何警報:( – Mahadevan