jQuery DatePicker最小最大日期 [英] jQuery DatePicker Min Max dates
本文介绍了jQuery DatePicker最小最大日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var expdisp = $( #expdisp)。attr(value);
$(#expirydate).datepicker({
showOn:button,
buttonImage:images / calendar.gif,
buttonImageOnly:true ,
dateFormat:dd / mm / yy,
defaultDate:expdisp,
showOtherMonths:true,
selectOtherMonths:true,
changeMonth:true,
changeYear:true,
});
解决方案
$ function(){
$(#datepicker).datepicker({
changeYear:true,
minDate:'-3M',
maxDate:'+ 28D',
});
});
更新
您可以计算游览最大和最小有效日期从默认日期,然后分配给日期选择器。
var expdisp = $(#expdisp)。attr (值);
$(#expirydate).datepicker({
showOn:button,
buttonImage:images / calendar.gif,
buttonImageOnly:true ,
dateFormat:dd / mm / yy,
defaultDate:expdisp,
showOtherMonths:true,
selectOtherMonths:true,
changeMonth:true,
changeYear:true,
minDate:'-3M',
maxDate:'+ 28D',
});
I have the jQuery date picker setup and working but would like help with setting the minDate and maxDate options. My current code is below (without these options). How can I set the minDate as 3 months before the defaultDate, and maxDate as 28days after the defaultDate?
var expdisp = $("#expdisp").attr("value");
$("#expirydate" ).datepicker({
showOn: "button",
buttonImage: "images/calendar.gif",
buttonImageOnly: true,
dateFormat: "dd/mm/yy",
defaultDate: expdisp,
showOtherMonths: true,
selectOtherMonths: true,
changeMonth: true,
changeYear: true,
});
解决方案
$(function() {
$( "#datepicker" ).datepicker({
changeYear: true,
minDate: '-3M',
maxDate: '+28D',
});
});
UPDATE
You can calculate tour max and min valid dates from the default date, then assign it to the date picker.
var expdisp = $("#expdisp").attr("value");
$("#expirydate" ).datepicker({
showOn: "button",
buttonImage: "images/calendar.gif",
buttonImageOnly: true,
dateFormat: "dd/mm/yy",
defaultDate: expdisp,
showOtherMonths: true,
selectOtherMonths: true,
changeMonth: true,
changeYear: true,
minDate: '-3M',
maxDate: '+28D',
});
这篇关于jQuery DatePicker最小最大日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文