Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
<script type="text/javascript">
    $(function() {
        $("#datepicker").datepicker({
            dateFormat: 'dd-mm-yy',
            defaultDate: -1,
            minDate: new Date(1, 07, 2013),
            maxDate: +0,
            firstDay: 1,
            changeMonth: true,
            changeYear: true

        });
    });
</script>

Date: <input type="text" id="datepicker" />


According to this it is static when month is changed it need change in code. but i want it change there min date according to current month automatic.

Please help me to solve that problem

Thanx with Regards
Ankush Sharma
Posted

1 solution

Following code will set minDate as First date of current month and maxdate as last date of current month.

JavaScript
var currentTime = new Date();
// First Date Of the month 
var startDateFrom = new Date(currentTime.getFullYear(),currentTime.getMonth(),1);
// Last Date Of the Month 
var startDateTo = new Date(currentTime.getFullYear(),currentTime.getMonth() +1,0);

$("#datepicker").datepicker({
    dateFormat: 'dd.mm.yy',
    minDate: startDateFrom,
    maxDate: startDateTo
});
 
Share this answer
 
v2
Comments
AnkushSharma100 15-Jul-13 6:42am    
Thanx sir,..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900