Date of Birth - How to Limit/Hide Dates >= 17 Years From Today

Hello, 

I have a date of birth input using the Datepicker component. I was able to restrict users to only enter dates <= 17 years from today. However, in the picker pop up, users still have to scroll back to their Date of Birth year. Ideally, I would like it to automatically start from Current Year - 17, so 2021 - 17 = 2004 in this instance. 

How it currently shows:



How I'd like it to be shown, in this instance:



5 Replies 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team November 8, 2021 08:56 AM UTC

Hi Shannon, 

Thanks for contacting Syncfusion support. 

You can achieve your requested requirement using the ‘Max Date’ and ‘Start’ property as like below code snippet. While opening the popup automatically starts from the current year and also the disabled the year will not have navigation arrow. 

<SfDatePicker TValue="DateTime?" Max='@MaxDate' Start='CalendarView.Decade'></SfDatePicker> 
 
@code { 
    public DateTime MaxDate { get; set; } = new DateTime(DateTime.Now.Year-17, DateTime.Now.Month, 1); 
} 

Output:  

 


Please get back us if you need further assistance. 

Regards, 
Ponmani M 


Marked as answer

SH Shannon November 8, 2021 01:24 PM UTC

Thanks for this, I do believe I have tried this but didn't work.. But will double check this evening when I get a chance! Thank you! Will update you. 



BC Berly Christopher Syncfusion Team November 9, 2021 12:06 PM UTC

Hi Shannon, 
  
We will wait until hear from you. 
  
Regards, 
Berly B.C 



SH Shannon November 28, 2021 08:33 PM UTC

Thanks Berly. 



BC Berly Christopher Syncfusion Team November 29, 2021 04:59 AM UTC

Hi Shannon, 
  
Most welcome. Please let us know if you need further assistance on this. 
  
  
Regards, 
Berly B.C 


Loader.
Up arrow icon