Jquery datapicker format and disable dates

hi all

i am using date picker for jquery

I want to disable future dates after today in this datepicker and change date format also.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="http://resources/demos/style.css">
  <script>
  $(function() {
       $("#datepicker").datepicker({dateFormat: 'dd-mm-yy'});
       $("#datepicker").datepicker({maxDate: 0});
         });
  </script>
</head>
<body>
 
<p>Date: <input type="text" id="datepicker"></p>
  
</body>
</html>

I am using max date:0 to make future dates disable.

 $("#datepicker").datepicker({maxDate: 0});

I am using this below codeline to format date.

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

Both of the above codelines work fine independently.

But they dont work together.

If i comment

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

then future dates get disable.

But i need to keep this date format line also.

So how can i make these both script lines run ??

How can i keep the date format also and make future dates disable ??

thanks
vineet

don’t initialise twice. you can put more than one property into an object.

Hi dormilich

you mean to say by using comma separator

vineet

have a look at the documentation. there are examples how to do it, e.g. http://jqueryui.com/datepicker/#min-max (click on the view source link).

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.