Saturday, June 1, 2024
 Popular · Latest · Hot · Upcoming
44
rated 0 times [  50] [ 6]  / answers: 1 / hits: 17018  / 12 Years ago, sat, september 29, 2012, 12:00:00

I am working on some project based on Twitter Bootstrap which using a datepicker from https://github.com/eternicode/bootstrap-datepicker (that is a fork from some other version), but it's missing a very important feature that I need - how to enable only specific date range (eg. from past 15 days till today), so any other date can't be even selected (not clickable).



I found a similar solution here on SO, which disables Saturdays and Sundays:
Limit bootstrap-datepicker to weekdays only?
http://jsfiddle.net/katowulf/zNbUT/5/ , but I dont know how to adjust it to my needs.



Thanks in advance.


More From » jquery

 Answers
34

The similar question you linked to ended up using quite a hack, but what you want is a lot simpler -- you're looking for the startDate and endDate options:



$('#dp1').datepicker({
format: 'mm-dd-yyyy',
startDate: '-15d',
endDate: '+0d' // there's no convenient right now notation yet
});


These options can take Date objects, timedelta strings (as I did here), or date strings following the given format.



Demo: http://jsfiddle.net/zNbUT/131/



Also, make sure you're using the code from github -- eyecon.ro's copy is the original code, with old bugs and without the newer features.


[#82846] Thursday, September 27, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tyreek

Total Points: 421
Total Questions: 115
Total Answers: 102

Location: Marshall Islands
Member since Mon, May 31, 2021
3 Years ago
tyreek questions
;