Search code examples
jquerydatepickermaxdate

jquery dd-mm-yyyy format and disabling future dates


I want the dates to be in dd-mm-yyyy format and have to block future dates from selection.

I am using the following code:

<script>
$( function() {
$( ".datepicker" ).datepicker({dateFormat: "dd-mm-yy"});
$( ".datepicker" ).datepicker({maxDate: "+0D" });
        } );
</script>

But only the first line in the function works; i.e. date is in dd-mm-yyyy but the disabling of future dates is not achieved.


Solution

  • Your code should look like this:

    $('.datepicker').datepicker({dateFormat: "dd-mm-yy", maxDate: 0});