user906568
user906568

Reputation: 471

Directly set UIDatePickers min, max date properties using jQuery

I have the following jQuery code to initialise a datepicker:

$( "#datepickertwo" ).datepicker(
          {
              dateFormat: 'dd-mm-yy',
              buttonImage: 'images/calendar.gif',
              showOn: "both",
              buttonImageOnly: true,
              maxDate: new Date(parseInt(<?php echo($maxDate[0]);?>),parseInt(<?php echo($maxDate[1]);?>),parseInt(<?php echo($maxDate[2]); ?>)),
              minDate: new Date(parseInt(<?php echo($minDate[0]);?>),parseInt(<?php echo($minDate[1]);?>),parseInt(<?php echo($minDate[2]); ?>)),         
          }

);

During user interaction, the datepicker's min and max dates will need to change.

My question is, how can I directly change the min max properties of the UIDatePicker after it has already been created?

Upvotes: 0

Views: 485

Answers (1)

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76880

I think you should do:

 var newMaxDate = //set your new date here
 $( "#datepickertwo" ).datepicker( "option" , 'maxDate', newMaxDate); 

Upvotes: 1

Related Questions