我的代码就像:
jQuery("#datepicker_checkin").datepicker({
minDate: 0,
numberOfMonths: 2,
showButtonPanel: true,
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd"
});
jQuery("#datepicker_checkout").datepicker({
beforeShow : function()
{
jQuery( this ).datepicker('option','minDate', jQuery('#datepicker_checkin').val() );
} ,
numberOfMonths: 2,
showButtonPanel: true,
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd"
});
jQuery("#datepicker_checkin").on('change', function() {
jQuery("#datepicker_checkout").val(jQuery('#datepicker_checkin').val());
jQuery("#datepicker_checkout").datepicker({
beforeShow : function()
{
jQuery( this ).datepicker('option','minDate', jQuery('#datepicker_checkin').val() );
} ,
numberOfMonths: 2,
showButtonPanel: true,
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd"
});
});
演示是这样的:DEMO
我这样描述:
如果我选择签入文本字段,那么签出文本字段将显示签出值+ 1
例如 :
如果签入= 2016-02-26然后签出= 2016-02-27
任何帮助,不胜感激
干杯
最佳答案
试试这个代码
$(function() {
$( "#check-in" ).datepicker({
numberOfMonths: 2,
showButtonPanel: true,
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd",
onSelect: function() {
var checkOutDate = $(this).datepicker('getDate');
checkOutDate.setDate(checkOutDate.getDate() + 1);
$( "#check-out" ).datepicker( "option", "minDate", checkOutDate );
$('#check-out').datepicker('setDate', checkOutDate);
}
});
$( "#check-out" ).datepicker({
numberOfMonths: 2,
showButtonPanel: true,
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd"
});
});
关于javascript - 如何显示“ checkin ”的jQuery datepicker值加“ checkout ”的值加1?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35192600/