set maxDate as currentDate in jquery-ui datepicker -
i trying set maxdate
currentdate
unfortunately, year dropdown doesn't updated. below i've.
var currentdate=new date(); var minyear=currentdate.getfullyear() - 80; var maxyear=currentdate.getfullyear() - 1; $('.datepicker').datepicker({ changemonth: true, changeyear: true, yearrange:minyear +':'+maxyear, showanim:'clip' });
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> <input type="text" class="datepicker"/>
my try included adding setdate
option date less year still dropdown value remained mindate
year. below tried:
var currentdate=new date(); var minyear=currentdate.getfullyear() - 80; var maxyear=currentdate.getfullyear() - 1; var setdates=new date(currentdate.getmonth()+"/"+currentdate.getdate()+"/"+(currentdate.getfullyear()-1)); $(".datepicker").datepicker({ changemonth: true, changeyear: true, yearrange:minyear +':'+maxyear, showanim:'clip', setdate:setdates });
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> <input type="text" class="datepicker"/>
any idea how can done?
we cane restrict range of selectable dates mindate
, maxdate
options. set beginning , end dates actual dates (new date(2009, 1 - 1, 26)),
numeric offset today (-20
), or string of periods , units ('+1m +10d'
).
$('.datepicker').datepicker({ changemonth: true, changeyear: true, mindate:'-80y', maxdate:'-1y', showanim:'clip' });
this works.
Comments
Post a Comment