Disable previous Dates in Input Type Date (TextMode Date) using jQuery in ASP.Net

Last Reply 7 months ago By dharmendr

Posted 7 months ago


i am using this textbox with textmode datetime i want calender should start from current date means user cannot select previous dates it should be locked.

<asp:TextBox ID="txtdateofreservation" runat="server" TextMode="Date"></asp:TextBox>


Posted 7 months ago Modified on 7 months ago

Hi nauna,

To disable previous dates use min attribute.

Check this example. Now please take its reference and correct your code.


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        var today = new Date();
        var month = ('0' + (today.getMonth() + 1)).slice(-2);
        var day = ('0' + today.getDate()).slice(-2);
        var year = today.getFullYear();
        var date = year + '-' + month + '-' + day;
        $('[id*=txtdateofreservation]').attr('min', date);
<asp:TextBox ID="txtdateofreservation" runat="server" TextMode="Date"></asp:TextBox>