Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  38] [ 2]  / answers: 1 / hits: 47153  / 9 Years ago, fri, july 3, 2015, 12:00:00

I have two datepickers like startdate and enddate.If i select 18th june 2015 in startdate i have to disable previous dates in datepicker to 18thjune2015 in enddate.



Here is my code.



 $(#txtstartdate).datepicker({ minDate: 0 });


For end-date:



    var startdate = $(#txtstartdate).val();
$(#txtenddate).datepicker({ minDate: startdate });


Its not working. Can anyone pls help me on this.
thank you.


More From » jquery

 Answers
8

You need to set it using the option method on change of start date





$(#txtstartdate).datepicker({
minDate: 0,
onSelect: function(date) {
$(#txtenddate).datepicker('option', 'minDate', date);
}
});

$(#txtenddate).datepicker({});

<script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js></script>
<link rel=stylesheet type=text/css href=http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/redmond/jquery-ui.css>
<script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.js></script>

<input id=txtstartdate />
<input id=txtenddate />




[#65939] Wednesday, July 1, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
piper

Total Points: 734
Total Questions: 93
Total Answers: 112

Location: Burundi
Member since Wed, Apr 6, 2022
2 Years ago
;