Topic: Datepicker date range
                  
                  fredemagi
                  pro
                  asked 7 years ago
                
                      
                      dschace
                      free
                        answered 6 years ago
                    
None of the above options actually work. I am a pro user. I copied the code provided by Mikolaj and it still only goes back 18 years. Dissapointing. The documentation does not provide any clear insight on how to get past this.
                      
                      tiago1
                      pro
                        answered 7 years ago
                    
Mikołaj Smoleński staff commented 7 years ago
Hi Tiago, You can find all available functionalities in our documentation: https://mdbootstrap.com/javascript/date-picker/
                      
                      Mikołaj Smoleński
                      staff
                        answered 7 years ago
                    
var dateObj = new Date();
var currentDay = dateObj.getUTCDate();
var currentMonth = dateObj.getUTCMonth();
var currentYear = dateObj.getUTCFullYear();
var maxYear = currentYear - 18;
var minYear = currentYear - 100;
$('.datepicker').pickadate({ 
 min: new Date(minYear, currentMonth, currentDay),
 max: new Date(maxYear, currentMonth, currentDay)
})
 
Regards
                    
                      fredemagi pro commented 7 years ago
Thanks, got it working ^_^.matis free commented 6 years ago
It does work, but what with the scrollbar? Now I do have option to choose right year, I can see it in Inspector, but how can I choose, for example, year 168?
Mikołaj Smoleński staff commented 6 years ago
Hi matis. For this moment we can't provide such solution. Best regards
                      
                      Bartłomiej Malanowski
                      staff
                        answered 7 years ago
                    
fredemagi pro commented 7 years ago
I did, but I couldn't make it work using ints. I was going to try to solve it using Javascript, but I'm a bit insecure on how to manipulate the date object >_>.Bartłomiej Malanowski staff commented 7 years ago
What's your code?fredemagi pro commented 7 years ago
https://ibb.co/kopa3n I discovered that the date range does not go too far back even if I tried to set min date to 2000. I want the min date to be from this date and then 100 years back and max date to be this date minus 18 years, meaning the user has to be at least 18 years old.FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
 - Premium support: No
 - Technology: General Bootstrap questions
 - MDB Version: -
 - Device: -
 - Browser: -
 - OS: -
 - Provided sample code: No
 - Provided link: No