Adrian Caspe
Adrian Caspe

Reputation: 17

Disable past dates in javascript datepicker (asp.net)

Can someone teach me how to disable dates in my js datepicker.

 <script type="text/javascript">



        $('.dateapick').fdatepicker({

            TodayHighlight: true,
            format: 'mm/dd/yyyy',
            disableDblClickSelection: true,
            leftArrow: '<<',
            rightArrow: '>>',
        });

Here's my datepicker (JS)

<asp:Textbox  runat="server" ID="txtStartDate"   OnTextChanged="txtStartDate_TextChanged" onchange="subtractDate(this.Id)" placeholder="MM/dd/yyyy" AutoPostBack="true"  Enabled="true"  CssClass="form-control pickadate"></asp:Textbox> 

and this is the front where i use my date.

Upvotes: 0

Views: 186

Answers (1)

Zohaib Ijaz
Zohaib Ijaz

Reputation: 22875

You can use onRender callback and based on your condition, return disabled or empty string

$('.dateapick').fdatepicker({

    TodayHighlight: true,
    format: 'mm/dd/yyyy',
    disableDblClickSelection: true,
    leftArrow: '<<',
    rightArrow: '>>',
    onRender: function (date) {
        return condition ? 'disabled' : '';
    }
});

Upvotes: 1

Related Questions