admin管理员组

文章数量:1313121

This is my datepicker field:

<div class="form-group">
              <label for="exampleInputBday">Birthday</label>
              <input type="text" name="bday" class="datepicker" required>
            </div>

This is my javascript:

$(function(){
        $('.datepicker').datepicker({
            startDate: '-3y',
            'format' : 'mm/dd/yyyy',
            autoclose: true
            })
        })
 })

When I open the datepicker, the start date is the current date! How to solve?

This is my datepicker field:

<div class="form-group">
              <label for="exampleInputBday">Birthday</label>
              <input type="text" name="bday" class="datepicker" required>
            </div>

This is my javascript:

$(function(){
        $('.datepicker').datepicker({
            startDate: '-3y',
            'format' : 'mm/dd/yyyy',
            autoclose: true
            })
        })
 })

When I open the datepicker, the start date is the current date! How to solve?

Share Improve this question asked Sep 17, 2013 at 20:01 user2297392user2297392 6
  • what do you mean by startDate? jQuery's datepicker widget doesn't such an option. do you mean minDate? – gdoron Commented Sep 17, 2013 at 20:04
  • The earliest date that may be selected; all earlier dates will be disabled. Is 'datepicker for boostrap' -> eternicode.github.io/bootstrap-datepicker – user2297392 Commented Sep 17, 2013 at 20:06
  • did you try startDate: '-1095', – adeneo Commented Sep 17, 2013 at 20:09
  • Thanks, but not worked... – user2297392 Commented Sep 17, 2013 at 20:13
  • Not sure I get it, startDate sets the earliest date that may be selected; all earlier dates will be disabled. Is this not what you're trying to do? If not, you should read the documentation, all you have to do is set the value of the element to whatever date you choose ? – adeneo Commented Sep 17, 2013 at 20:34
 |  Show 1 more ment

1 Answer 1

Reset to default 2

This should do the trick. When you are defining the date picker, you can use setDate option:

$(".datepicker").datepicker("setDate", "10/12/2013");

本文标签: javascriptSet 39Start Date39 on Datepicker for BootstrapStack Overflow