-6

i am using bootstrap-datepicker.js to take date of birth from calendar,i need to disabled past date and it should be enabled after 18 years in calendar. Please help me to resolved this issue.

  • 1
    Use moment.js it has all the functionality required by you! – Ullas Hunka Jun 07 '18 at 13:45
  • 3
    Your code is the bootstrap-datepicker plugin...? Please show us the code you wrote to attempt to solve this. – Rory McCrossan Jun 07 '18 at 13:46
  • 1
    No one wants to read that wall of code and guess what your error might be. Please read [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and more importantly, please include a [minimal, verifyable and complete example](https://stackoverflow.com/help/mcve). – Thomas Flinkow Jun 07 '18 at 14:00

2 Answers2

2

This is using moment.js

moment("1999-03-22").isBefore(moment().subtract(18, "years"))

It will return true if the date in the first parenthesis is at least 18 years ago based on the current date.

Francesco
  • 429
  • 4
  • 12
0

Could try initialising it with the max date attribute set

$("#datePickerId").datepicker({
    maxDate: "-18Y"
});

jQuery datepicker mindate, maxdate

iainc123
  • 56
  • 1
  • 5