fredemagi pro asked 5 years ago

Hi, How do I set a min date of today's date minus 100 years (that would be the 30th of april, 1918 as of this writing), and a max date of today's date minus 18 years (30th of april, 2000) using datepicker?   Regards, Frederik

dschace free answered 4 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.

Bartłomiej Malanowski staff commented 4 years ago

What's your version of MDB?

tiago1 pro answered 5 years ago

Hi guys, please, do you have any example of code similar to this calendar range?   thanks

Mikołaj Smoleński staff commented 5 years ago

Hi Tiago, You can find all available functionalities in our documentation:

Mikołaj Smoleński staff answered 5 years ago

Hi fredemagi, Could You please try the following code:
var dateObj = new Date();
var currentDay = dateObj.getUTCDate();
var currentMonth = dateObj.getUTCMonth();
var currentYear = dateObj.getUTCFullYear();
var maxYear = currentYear - 18;
var minYear = currentYear - 100;
 min: new Date(minYear, currentMonth, currentDay),
 max: new Date(maxYear, currentMonth, currentDay)

fredemagi pro commented 5 years ago

Thanks, got it working ^_^.

matis free commented 4 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 4 years ago

Hi matis. For this moment we can't provide such solution. Best regards

Hey, Did you check our docs for Date Picker? I'm sure you'll find an answer there ;) I think the `min` and `max` options is what are you looking for

fredemagi pro commented 5 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 5 years ago

What's your code?

fredemagi pro commented 5 years ago 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.

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • User: Pro
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No