Last active
August 29, 2015 14:23
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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