Click here to Skip to main content
15,906,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
$('.DateOfBirth').datepicker({
           changeMonth: true,
           changeYear: true,
           dateFormat: 'dd/mm/yy',
           defaultDate: new Date(),
         yearRange: "-100:+0"

       });


The above code brings a list of years ranging : 2017 to 1917 in the year dropdown of datepicker.

Now when i select a year say 2000 the dropdown sets the year value to 2000 which is correct and it works fine till 2000 but if i select a year before 2000 say 1999 etc the dropdown displays the first year i.e 1917 in dropdown selection, but if i select the date it populates the selected year 1999 date eg 23/08/1999 which is correct but the dropdown still has 1917 displayed on it.

Note : the textbox having the above class and the above code is in a partial view which is displayed on a View.

The month dropdown works perfectly, its just the year dropdown creating problem. Also i removed yearRannge attribute and tried still it doesnt work.
if yearRange = -100:+0 so 1917 is selected if i choose any year before 2000
if yearRange = -100:+100 so if i select 1950 it selects 2050 , if 1970 it selects 2070 and so on.

What I have tried:

I tried calling onselect functions but didnt work for me.
Posted
Updated 17-Apr-17 22:12pm
v4
Comments
Karthik_Mahalingam 5-Apr-17 7:19am    
have tested your code, it works fine.
which version of jquery are you using?
Abrar Kazi 5-Apr-17 7:23am    
1.11
Karthik_Mahalingam 5-Apr-17 7:28am    
i have tried with 1.12.1 the one in jquery ui demo page
Abrar Kazi 5-Apr-17 7:31am    
what possibly could go wrong here i cannot upgrade to 1.12
Abrar Kazi 5-Apr-17 7:23am    
can we skype i can share images ?

1 solution

Update jquery. This is the only solution i found for this issue. Thanks to Karthik.
 
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