Ben
Ben

Reputation: 702

jquery datepicker daterange, specify start year

I'm using the date range with jquerydate picker.

<script>
            jQuery(document).ready(function(){
                // binds form submission and fields to the validation engine
                jQuery("form").validationEngine();

    $('.datepicker').datepicker({
     changeMonth: true,
     changeYear: true,
     yearRange: '-14:-75'
    });

            });
</script>

The problem is then that the drop down box starts at 1936, where as I would like it to start at the other end of the scale. Can anyone help

Upvotes: 0

Views: 4349

Answers (1)

JMax
JMax

Reputation: 26591

You can use the defaultDate option: http://jqueryui.com/demos/datepicker/#option-defaultDate

jQuery(document).ready(function() {
    // binds form submission and fields to the validation engine
    // jQuery("form").validationEngine();
    var myDate = new Date("March 21, 1997");

    $('.datepicker').datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: '-14:-75',
        defaultDate: myDate
    });

});

See on this jsfiddle

Upvotes: 2

Related Questions