问题
I have two dates, Start date and End date. I need to validate the the end date should not greater than the start date.
need to clear (previous start date value) the date value when ever we change the date.
- case 1# [ First time] start date - 23-Nov-2013 End date - 24-Nov-2013
now i changed the start date as -25-Nov-2013, but end date enabled the the 24-Nov-2013 (start previous value) on wards instead of 26-Nov-203.
So, i need to clear the value when ever i change the date.
回答1:
Actually, what that 27/11/2013 represents is the current Date. Which will not get updated unless you write it on changeDate event.
So you have to do like
- Bind the
start date, withchangeDateevent. - Increment the selected date in start.
- Again set back the incremented date.
Now update this to
end Dateusingupdatemethod$('#end').datepicker('update', toDate);
Finally, you code will be like
$('#start').datepicker({}).on('changeDate', function (ev) {
var toDate = ev.date;
toDate.setDate(toDate.getDate() + 1);
$('#end').datepicker('update', toDate);
});
$('#end').datepicker({});
JSFiddle
来源:https://stackoverflow.com/questions/20235758/bootstrap-date-picker-clear-value