Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save interactivellama/eee7795377b2914ca1c4 to your computer and use it in GitHub Desktop.
Save interactivellama/eee7795377b2914ca1c4 to your computer and use it in GitHub Desktop.
Set Fuel UX datepicker to restrict all dates but today and the previous year
var today = new Date();
var tomorrow = new Date();
tomorrow = new Date(tomorrow.setDate(tomorrow.getDate() + 1));
var aYearAgo = new Date(today.getTime());
aYearAgo.setFullYear(aYearAgo.getFullYear() - 1);
document.write(today + '<br\>');
document.write(aYearAgo + '<br\>');
document.write(tomorrow + '<br\>');
// initialize
$('#myDatepicker').datepicker({
allowPastDates: true,
restricted: [{
from: -Infinity,
to: aYearAgo
},
{
from: tomorrow,
to: Infinity
}]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment