Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.