admin管理员组文章数量:1350912
I am using jquery date picker .I want to set max and minimum value of calendar ? how to set this value Example minimum value is 1990 and maximum is 2050
$( "#inputBirthDate" ).datepicker({
changeMonth: true,
changeYear: true
});
<input class="span6 date_h nativedatepicker" id="inputBirthDate" type="text" style="pointer-event:none; width:240px;" readonly>
I am using jquery date picker .I want to set max and minimum value of calendar ? how to set this value Example minimum value is 1990 and maximum is 2050
$( "#inputBirthDate" ).datepicker({
changeMonth: true,
changeYear: true
});
<input class="span6 date_h nativedatepicker" id="inputBirthDate" type="text" style="pointer-event:none; width:240px;" readonly>
Share
Improve this question
asked Oct 8, 2013 at 6:17
user2075328user2075328
4413 gold badges7 silver badges16 bronze badges
1
- 4 Have you even goggled it, there are lot of question with this problem already answered. you will get your answer from there. :) – Vinay Pratap Singh Bhadauria Commented Oct 8, 2013 at 6:20
7 Answers
Reset to default 3You need to use min-date and max-date option to set the min and max selectable date.
$("#inputBirthDate").datepicker({
changeMonth: true,
changeYear: true,
minDate: new Date(2007, 1 - 1, 1),
maxDate: new Date(2012, 1 - 1, 1),
});
Try this
$("#inputBirthDate" ).datepicker( { minDate: -0, maxDate: new Date(2020, 1,18) });
Min Date
Max Date
Plz read the documentation before going to use it: Link
$(function() {
$( "#datepicker" ).datepicker({ minDate: -20, maxDate: "+1M +10D" });
});
try it..
<script>
$(function(){
$( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function() {
var date = $(this).datepicker('getDate');
if (date){
date.setDate(date.getDate() + 1);
$( "#to" ).datepicker( "option", "minDate", date );
}
}
});
$( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function() {
var date = $(this).datepicker('getDate');
if (date) {
date.setDate(date.getDate() - 1);
$( "#from" ).datepicker( "option", "maxDate", date );
}
}
});
})
just use minDate / maxDate attribute like this:
$( "#datepicker" ).datepicker({
minDate: 'some value',
maxDate: 'some other value',
});
try :
$('#datepicker').datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true,
minDate: new Date(1990-01-01),
maxDate: new Date(2050-01-01),
inline: true
});
this one worked for me, with date format
$( "#from_date" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat: 'dd/mm/yy',
onClose: function() {
var date = $(this).datepicker('getDate');
if (date){
date.setDate(date.getDate() + 1);
$( "#to_date" ).datepicker( "option", "minDate", date );
}
}
});
$( "#to_date" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat: 'dd/mm/yy',
onClose: function() {
var date = $(this).datepicker('getDate');
if (date) {
date.setDate(date.getDate() - 1);
$( "#from_date" ).datepicker( "option", "maxDate", date );
}
}
});
本文标签: javascripthow to set minimum and maximum value of date picker in jqueryStack Overflow
版权声明:本文标题:javascript - how to set minimum and maximum value of date picker in jquery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743886064a2556079.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论