Yii2 datepicker disables dates using javascript

I rewrote my question:

I am using Kartick DatePicker to display datepicker. On this datepicker, I want to disable dates using javascript. Here is what I have:

<?= DatePicker::widget([ 'name' => 'mydate', 'language' => 'fr', 'clientOptions' => [ 'autoclose' => true, 'format' => 'dd-M-yyyy' ] ]);?> 

Using JS:

  $(function(){ $("#w0").datepicker("setDatesDisabled", ['25-08-2017']); }); 

I tried changing the date format to 2017/08/25 or 08/25/2017 , but nothing is displayed in the logs anyway.

I also tried using kvDatepicker() instead of datepicker() , but that gave me

Uncaught TypeError: $ (...). kvDatepicker is not a function

Any hint of what's wrong here? Thanks x.

+7
javascript jquery yii2 datepicker
source share
1 answer

Your date is not in that format. It should be specified as:

 $("#w0").datepicker("setDatesDisabled", ['08/25/2017']); 

Of course, make sure w0 is the correct identifier for the input element ... it could also be that your selector does not match input .

I checked on the demo page, which enters this in the browser console, correctly disables August 28th:

 $('#sandbox-container input').datepicker("setDatesDisabled", ['08/28/2017']); 
+6
source share

All Articles