Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello there,

I am trying to implement jquery ui datepicker and what i am trying to do is the following ;
1.Allow the user to selct only the current and previous months
2.The full month should be selectable( i used minDate:-1m , but this allows you to select only certain days in the month not all of the dates)

This is the configuration i have so far , any input would be much appreshiated :

What I have tried:

$('#<%=Date.ClientID %>').datepicker({
              dateFormat: 'dd/mm/yy', numberOfMonths: 2, minDate: "-1M",
              maxDate: "+0M"
          });
Posted
Updated 4-Jun-17 21:20pm
Comments
Kornfeld Eliyahu Peter 5-Jun-17 3:01am    
You have to set minDate to the FIRST DAY of the previous month and not to one month before today (-1M)...
In the same way you have to set maxDate to the LAST DAY of the current month...

1 solution

1.Allow the user to select only the current and previous months

2.The full month should be selectable
C#
var date = new Date();
var MaxDate= new Date(date.getFullYear(), date.getMonth() + 1, 0);

Just set max date to the calender and you are done.
 
Share this answer
 

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