使用当前的代码,我可以进行一年的经验计算,如何检查重叠的日期。例如,如果用户从原始div 19/5/2005-18/6/2015中选择一次,如果用户选择19/3/2003-18/6/2016,则用户单击克隆的div中的添加更多按钮。它应该说一个警告消息。
这是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);
});
这是小提琴链接
请给我建议。
谢谢与问候马哈德万
您正在浏览日期
$.each($(dateStart),function(key,value)
您正在捕获日期和差异,但没有比较前一个日期
if(dateStart[key-1])
上面的代码将帮助您使用key-1获取先前的行值,并且您可以比较日期
请参考小提琴网址http://jsfiddle.net/ZigmaEmpire/bqgjro6d/7/日期格式为MM-DD-YYYY
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句