KPM KPM - 10 months ago 44
Javascript Question

JQuery DatePicker Default Date 18 years ago

I'm trying to get my jquery datepicker to default to open on 18 years in the past (user must be 18 or over to use app) and I don't want them to be able to select any date that isn't 18 years or more in the past. I have this code but I can't get it to work apart from showing the default todays date. Any help would be appreciated. Thanks.

<link rel="stylesheet" type="text/css" href="css/datepicker.css">
<script type="text/javascript" src="js/bootstrap-datepicker.js"></script>
<script type="text/javascript">
$(document).ready(function() {

$('#datepicker').datepicker().on('changeDate', function(ev){


Create the datepicker by datepicker method and setDate

 $( "#datepicker" ).datepicker();