Margate
Margate

Reputation: 421

jQuery datepicker begin at future date

I have added a jQuery date picker into my site but do not want anyone to be able to select a date before 1st June 2014. With the code I have it is fine but it changes every day! The datepicker has been on my site now for 9 days and I set it to 1st June 2014, problem is as each day passes the calender changes. Currently I am able to only select from 10th June! I think this must be because of the minDate setting but how do i stop this from changing every day? Thank you for any help.

Code as follows:

    <script type="text/javascript">
    $(document).ready(function() {
    $("#datepicker").datepicker({minDate: 129, maxDate: "+5Y", changeMonth: true,changeYear: true, showButtonPanel: true, dateFormat: 'dd MM yy'});
    });

    $('#form').on('submit', function(){
    return $('#email').val() == $('#emailConfirmation').val();
    });
</script>

Upvotes: 0

Views: 175

Answers (2)

mpowroznik
mpowroznik

Reputation: 1022

$(function () {
     $("#datepicker").datepicker({
         minDate: new Date(2014, 5, 1)
     });
});

Upvotes: 1

adeneo
adeneo

Reputation: 318252

You can just set the minDate to a specific date instead of number of days from today

$("#datepicker").datepicker({
    minDate: '06 June 2014',
    maxDate: "+5Y",
    changeMonth: true,
    changeYear: true,
    showButtonPanel: true,
    dateFormat: 'dd MM yy'
});

FIDDLE

Upvotes: 2

Related Questions