javascript - Change jQuery daterange picker to disallow a date range if it contains disabled dates -
i have created jquery date range picker. able select dates ranges , show them in textbox. need is, need disable dates , assign different classes dates.
e.g. must able give class april 2, class b april 4 etc.
i have tried results got while googled nothing helped. trying pass dates , classes should assigned dates. class should assigned dates plus must have option enable or disable dates.
the next thing trying if there disabled date in between 2 dates, range cannot selected.
e.g. suppose want select april 2 april 7 , april 5 disabled date. able select either april 2 april 4 or april 6 april 7.
that means 1 range should selectable. please solve this.
please find fiddle here:
you have create 2 arrays, 1 maps css class each date want disabled class:date
, , 1 maps css class date want give special class, , then:
- inside
beforeshowday
, check if date in disabled dates array, , if find it, use associated class , return false, example:[false,"classa"]
, if not , check in special array , return class true, else whatever doing right now. - inside
onselect
, check if selected range includes of dates in array , act accordingly - then in
class:date
array, can addclass:date
desire disabled own class, , code handle it
full working solution here.
notes:
- the code disables 22nd of april , 15th of may (try playing dates)
- the code gives special class 15th of april , 10th of may.
- the css class applies
background-color
ontd
, does't show properly, have modify picker's css do - reference hepled me provide answer here
Comments
Post a Comment