hollyquinn
hollyquinn

Reputation: 652

Datepicker don't allow past dates plus today

Hi I have a bootstrap datepicker. I want to grey out all past dates plus the date today on the calendar. I know that I can grey out all past dates with this:

<script type="text/javascript">
$(function () {
    $('#delayed-spiffdate').datepicker({
        startDate: '-0d'
    });
});

But how do I grey out the current date? Thanks.

Upvotes: 0

Views: 83

Answers (2)

wesww
wesww

Reputation: 2873

War10ck's answer is the cleanest. Worth noting, you can also set your datepicker parameters to whatever you like using a date object. Here's another answer that also works:

$(function () {
    $('#delayed-spiffdate').datepicker({
        startDate: new Date(new Date().getTime() + 24 * 60 * 60 * 1000)
    });
});

http://jsfiddle.net/qy8kvf39/

Upvotes: 0

War10ck
War10ck

Reputation: 12508

If you want to exclude all past dates and today as well, then you need your startDate value to be +1d:

$(function () {
    $('#delayed-spiffdate').datepicker({
        startDate: '+1d'
    });
});

DEMO: jsfiddle

Upvotes: 2

Related Questions