如何将当前月份的第一个日期设置为minDate datepicker jquery UI [英] how to set first date of current month as minDate datepicker jquery UI
本文介绍了如何将当前月份的第一个日期设置为minDate datepicker jquery UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker({
dateFormat: 'dd-mm-yy',
defaultDate: -1,
minDate: new Date(1, 07, 2013),
maxDate: +0,
firstDay: 1,
changeMonth: true,
changeYear: true
});
});
</script>
Date: <input type="text" id="datepicker" />
根据这个,当月份改变时它是静态的,它需要改变代码。但我希望它根据当前月份自动更改最小日期。
请帮我解决这个问题
Thanx with Regards
Ankush Sharma
According to this it is static when month is changed it need change in code. but i want it change there min date according to current month automatic.
Please help me to solve that problem
Thanx with Regards
Ankush Sharma
推荐答案
(function(){
(function() {
( #datepicker)。datepicker({
dateFormat:' dd-mm-yy',
defaultDate:-1,
minDate: new 日期( 1 , 07 , 2013 ),
maxDate:+ 0,
firstDay: 1 ,
changeMonth: true ,
changeYear: true
});
} );
< / script >
日期:< input type = text id = datepicker />
("#datepicker").datepicker({ dateFormat: 'dd-mm-yy', defaultDate: -1, minDate: new Date(1, 07, 2013), maxDate: +0, firstDay: 1, changeMonth: true, changeYear: true }); }); </script> Date: <input type="text" id="datepicker" />
根据这个,当月份改变时它是静态的,它需要改变代码。但我希望它根据当前月份自动更改最小日期。
请帮我解决这个问题
Thanx with Regards
Ankush Sharma
According to this it is static when month is changed it need change in code. but i want it change there min date according to current month automatic.
Please help me to solve that problem
Thanx with Regards
Ankush Sharma
以下代码将minDate设置为当前月份的第一个日期,并将maxdate设置为当月的最后日期。
Following code will set minDate as First date of current month and maxdate as last date of current month.
var currentTime = new Date();
// First Date Of the month
var startDateFrom = new Date(currentTime.getFullYear(),currentTime.getMonth(),1);
// Last Date Of the Month
var startDateTo = new Date(currentTime.getFullYear(),currentTime.getMonth() +1,0);
这篇关于如何将当前月份的第一个日期设置为minDate datepicker jquery UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文