jquery UI日期选择器克隆重叠年份如何计算
jquery UI date picker clone overlapping years how to calculate
使用我当前的代码,我能够计算经验年限如何检查重叠日期。例如,如果用户 select 来自原始 div
19/5/2005 - 18/6/2015 一旦用户单击克隆 div 中的添加更多按钮,如果用户 select 19/3/2003 - 18/6/2016。它应该会显示一条警告消息。
这是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);
});
这里是fiddleLink
请多多指教。
感谢和问候
马哈德文
您正在循环浏览日期
$.each($(dateStart),function(key,value)
您正在捕获日期和差异,但您没有比较之前的起始日期
if(dateStart[key-1])
以上代码将帮助您使用 key-1 获取前几行的值,您可以比较日期
请参考fiddle URL http://jsfiddle.net/ZigmaEmpire/bqgjro6d/7/
日期格式为 MM-DD-YYYY
使用我当前的代码,我能够计算经验年限如何检查重叠日期。例如,如果用户 select 来自原始 div 19/5/2005 - 18/6/2015 一旦用户单击克隆 div 中的添加更多按钮,如果用户 select 19/3/2003 - 18/6/2016。它应该会显示一条警告消息。
这是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);
});
这里是fiddleLink
请多多指教。
感谢和问候 马哈德文
您正在循环浏览日期
$.each($(dateStart),function(key,value)
您正在捕获日期和差异,但您没有比较之前的起始日期
if(dateStart[key-1])
以上代码将帮助您使用 key-1 获取前几行的值,您可以比较日期
请参考fiddle URL http://jsfiddle.net/ZigmaEmpire/bqgjro6d/7/ 日期格式为 MM-DD-YYYY