I have two datepickers (jqueryui) and I would like to restrict the second inputs (minDate property) to the value selected in first. How should I do this? I wrote the following code, without success:
$("#picker1").button().click(function() {
var minDate = $( "#picker1" ).datepicker( "getDate" );
$( "#picker2" ).datepicker( "option", "minDate", minDate );
$( "#picker2" ).datepicker( "refresh");
});
Can you help me with this?
Thanks!
Syntax: $( ". selector" ). datepicker({ minDate: new Date(2007, 1 - 1, 1) });
To change the position of the jQuery UI Datepicker just modify . ui-datepicker in the css file. The size of the Datepicker can also be changed in this way, just adjust the font size.
Step 1: Create a DateTimePicker using the DateTimePicker() constructor is provided by the DateTimePicker class. // Creating a DateTimePicker DateTimePicker dt = new DateTimePicker(); Step 2: After creating DateTimePicker, set the MinDate property of the DateTimePicker provided by the DateTimePicker class.
Syntax: $(". selector"). datepicker( {defaultDate:"+6"} );
Try
$('#p1, #p2').datepicker();
$('#p1').change(function(){
$('#p2').datepicker('option', 'minDate', $('#p1').datepicker('getDate'))
});
Demo: Fiddle
I suspect getDate
returning string .You can try like this.
$("#picker1").button().click(function() {
var minDate = $( "#picker1" ).datepicker( "getDate" );
$( "#picker2" ).datepicker( "option", "minDate", new Date(minDate));
$( "#picker2" ).datepicker( "refresh");
});
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