I am trying to make a input field for the users birthday. For this I would like them to only select years in the past.
How do I achieve this? I tried entering a negative number in the selectYears
property but no luck.
JSFIDDLE
HTML:
<div class="col s12">
<label for="birthday">Birthday</label>
<input id="birthday" value="{{ user.birthday }}" type="date" name="birthday" class="datepicker">
</div>
JavaScript:
$('.datepicker').pickadate(
{
selectMonths: true,
selectYears: -100
});
I am trying to make a input field for the users birthday. For this I would like them to only select years in the past.
How do I achieve this? I tried entering a negative number in the selectYears
property but no luck.
JSFIDDLE
HTML:
<div class="col s12">
<label for="birthday">Birthday</label>
<input id="birthday" value="{{ user.birthday }}" type="date" name="birthday" class="datepicker">
</div>
JavaScript:
$('.datepicker').pickadate(
{
selectMonths: true,
selectYears: -100
});
Share
Improve this question
asked Nov 14, 2015 at 22:40
Trevi AwaterTrevi Awater
2,4072 gold badges33 silver badges55 bronze badges
2 Answers
Reset to default 3var d = new Date();
d.setFullYear( d.getFullYear() - 100 );
$('.datepicker').pickadate(
{
selectMonths: true,
selectYears: d,
max: new Date()
});
This will actually give full list of 100 past years.
This is how you set the year:
var d = new Date();
d.setFullYear( d.getFullYear() - 100 );
$('.datepicker').pickadate(
{
selectMonths: true,
selectYears: true,
min: d,
max: new Date()
});
http://jsfiddle/rpu61tf2/3/
You set selectYears: true
when you want to allow your users to select the years from a drop down
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744946110a4602626.html
评论列表(0条)