I have used following code for this but it is not working. please help me to do it.
$(document).ready(function () {
        $('.datepicker').datepicker({
            format: 'mm-dd-yyyy',
            autoclose:true,
            endDate: "today",
        }).on('changeDate', function (ev) {
                $(this).datepicker('hide');
            });
        $('.datepicker').keyup(function () {
            if (this.value.match(/[^0-9]/g)) {
                this.value = this.value.replace(/[^0-9^-]/g, '');
            }
        });
    });
                You can do this: Datepicker has an option maxDate
$(document).ready(function () {
        var today = new Date();
        $('.datepicker').datepicker({
            format: 'mm-dd-yyyy',
            autoclose:true,
            endDate: "today",
            maxDate: today
        }).on('changeDate', function (ev) {
                $(this).datepicker('hide');
            });
        $('.datepicker').keyup(function () {
            if (this.value.match(/[^0-9]/g)) {
                this.value = this.value.replace(/[^0-9^-]/g, '');
            }
        });
    });
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<p>Select Date: <input type="text" class="datepicker"></p>
using maxDate:'0' you can acchive this.
Working fiddle
$("#datepicker").datepicker({
  dateFormat: 'yy-mm-dd ',
  maxDate:'0'
});
                        If you want to future date disable from today use today.getFullYear() - 10 in order to disable 10 years before which means disable from 2008.
<script>
 $(document).ready(function(){
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear()-10; // change according to year 0 for current
var today1 = mm + '/' + dd + '/' + yyyy;
$("#birthday").datepicker({
     endDate:today1,
    });
});
</script>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With