Javascript 如何显示签入的jquery datepicker值加上签出的1 In值?
我的代码如下:Javascript 如何显示签入的jquery datepicker值加上签出的1 In值?,javascript,jquery,html,css,datepicker,Javascript,Jquery,Html,Css,Datepicker,我的代码如下: jQuery("#datepicker_checkin").datepicker({ minDate: 0, numberOfMonths: 2, showButtonPanel: true, changeMonth: true, changeYear: true, dateFormat: "yy-mm-dd" }); jQuery("#datepicker_checkout").datepicker({ befor
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"
});
});
演示如下:
我这样描述:
如果我选择签入的文本字段,则签出的文本字段将显示签出值+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"
});
});
根据示例添加+1d,希望这能对您有所帮助。试试这个mate@guradio,我更新了我的问题我想fiddle可以解决它?你不这么认为吗?@guradio,你是什么意思?你检查过小提琴了吗?我不明白你真正想要的是什么。此代码在选择时的签出输入中显示签入日期+1,并将其设置为最小日期。这是你的问题。我错了吗?别担心,萨缪尔托。很高兴我帮了你,我需要你的帮助。看这里:
$('.pickupDate').change(function() {
var date2 = $('.pickupDate').datepicker('getDate', '+1d');
date2.setDate(date2.getDate()+1);
$('.dropoffDate').datepicker('setDate', date2);
});