我需要jquery日期选择器的帮助我有两个文本框一个用于检查和其他检查...我想要1天加入结帐框 这是我的代码,我无法提前1天在结帐时获取日期... plz help
$("#CheckInDatePicker").datepicker({
defaultDate: "+1w",
minDate: 0,
changeMonth: true,
showOn: "button",
buttonImage: "/Images/Base/calander.png",
numberOfMonths: 2,
showButtonPanel: true,
buttonImageOnly: true,
onSelect: function (selectedDate) {
var minDate = $(this).datepicker('getDate');
if (minDate) {
minDate.setDate(minDate.getDate() + 1);
}
$("#CheckOutDatePicker").datepicker("option", "minDate", minDate || 1);
}
答案 0 :(得分:0)
$("#CheckInDatePicker").datepicker({
defaultDate: "+1w",
minDate: 1,
changeMonth: true,
showOn: "button",
buttonImage: "/Images/Base/calander.png",
numberOfMonths: 2,
showButtonPanel: true,
buttonImageOnly: true,
更改你的日期延长一天的minDate
答案 1 :(得分:0)
尝试一下..并在尝试之前清除浏览器缓存..
onSelect: function(dateValue, inst) {
$('#CheckOutDatePicker').datepicker();
var date2 = $('#CheckInDatePicker').datepicker('getDate', '+1d');
$('#CheckOutDatePicker').datepicker('destroy');
date2.setDate(date2.getDate() + 1);
$('#CheckOutDatePicker').datepicker({
minDate: date2,
dateFormat: "yy-mm-dd",
onSelect: function() {
//Do whatever you want to do
}
});
}
查看
答案 2 :(得分:0)
/*DATE PICKER FUNCTION START*/
var today = new Date();
$(function() {
$( "#date_from" ).datepicker({
defaultDate: "+0w",
changeMonth: true,
dateFormat: "yy-mm-dd",
numberOfMonths: 1,
onSelect: function( selectedDate ) {
if($( "#date_to" ).val() == ""){
/*console.log(selectedDate);
var dateString = selectedDate; // date string
var actualDate = new Date(dateString); // convert to actual date
var newDate = new Date(actualDate.getFullYear(), actualDate.getMonth(), actualDate.getDate()+1); // create new increased date
console.log(actualDate.getMonth());
// now extract the bits we want to crete the text version of the new date..
var newDateString = (newDate.getFullYear()+'-'+newDate.getMonth()+'-'+newDate.getDate());
console.log(newDateString);*/
$( "#date_to" ).datepicker( "option", "minDate", selectedDate );
}
}
});
$( "#date_to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
dateFormat: "yy-mm-dd",
numberOfMonths: 1,
minDate: "+1d",
onSelect: function( selectedDate ) {
$( "#date_from" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
/*DATE PICKER FUNCTION END*/
根据需要更改字段名称...我希望这可行
答案 3 :(得分:0)
$(document).ready(function() {
$( "#saledate" ).datepicker({ maxDate: "+1d", dateFormat: 'dd/mm/yy' });
$("#saledate").datepicker("option","defaultDate", "<?=date("d/m/Y");?>");
});
试试这段代码#saledate是datepicker字段的id。