I have a JqueryUI datepicker on which I only want dates 5-days-out (or more) to be available. This works fine for that...
var dateToday = new Date();
$( "#datepicker" ).datepicker({
minDate: '+1w', // your min date
beforeShowDay: $.datepicker.noWeekends // disable weekends
});
I also have a checkbox that, IF CHECKED, essentially overrides the minDate and makes the minDate available TODAY's date (rather than a week out):
<input type="checkbox" class="lessThanFiveDays" value="1" name="less-than-5-days" />I need this earlier than the standard 5 business days
I'm struggling with where the checkbox checking JQuery needs to go and in what order. Also, do I just check if the box is checked, or does the altering of the datepicker params need to happen on a "change" event on the checkbox.
This below is wrong, but hopefully it helps illustrate how I'm confusing myself:
$( "#datepicker" ).datepicker({
minDate: '+1w', // your min date
beforeShowDay: $.datepicker.noWeekends // disable weekends*/
});
$('.lessThanFiveDays').change(function() {
if($(this).is(":checked")) {
$( "#datepicker" ).datepicker({
minDate: dateToday, // your min date
beforeShowDay: $.datepicker.noWeekends // disable weekends*/
});
}
Aucun commentaire:
Enregistrer un commentaire