Reputation: 506
I have script as below:
<script>
$(document).ready(function() {
$("#sDate , #eDate").datepicker({
dateFormat: 'yy-mm-dd',
showOn: "button",
buttonImage: "images/calendar.gif",
buttonImageOnly: true
});
});
My html input fields are as follows:
<input type="text" readonly name="scheduleStartDate" id="sDate" />
<input type="text" readonly name="scheduleEndDate" id="eDate" />
when I click on image, I'm getting the ui calender for input fields, Please help me to disable previous dates in the calender so that the user can only select the start date from today's date and onwards. Thank you!
Upvotes: 3
Views: 73
Reputation: 137
Use minDate
attribute to your code like this
<script>
$(document).ready(function(){
$( "#sDate , #eDate" ).datepicker({
dateFormat: 'yy-mm-dd',
showOn: "button",
buttonImage: "images/calendar.gif",
buttonImageOnly: true,
minDate: new Date(2015, 6, 29)
});
});
</script>
Where 2015 is the year, 6 is the month and 29 is the date. The date before 29/06/2015 will be disabled.
Note: Assuming the datepicker you've used is jQuery datepicker.
Upvotes: 1