'+J.settings.navigation[0]+(bt?"︎":"")+' | '+J.settings.navigation[1]+(bt?"︎":"")+' |
'+gt+' | '+J.settings.lang_clear_date+' |
q(o(dt,$(ot,2)))))return!0;if(4===e&&(void 0!==H&&t=i.length?0:n+1:n-1<0?i.length-1:n-1;"hour"===t[1]?S=i[e]:"minute"===t[1]?ct=i[e]:"second"===t[1]?lt=i[e]:Y=i[e],w=(w=!w&&J.settings.start_date&&(n=yt(J.settings.start_date))?n.getDate():w)||C,s.text($(i[e],2).toUpperCase()),Pt(O,j,w)},Pt=function(t,e,s,n,i){var a=new Date(t,e,s,L&&L.hours?S+(L.ampm?"pm"===Y&&12!==S?12:"am"===Y&&12===S?-12:0:0):12,L&&L.minutes?ct:0,L&&L.seconds?lt:0),r="days"===n?p:"months"===n?d:c,o=kt(a);G.val(o),(J.settings.always_visible||L)&&(nt=a.getMonth(),j=a.getMonth(),k=a.getFullYear(),O=a.getFullYear(),w=a.getDate(),i)&&r&&(r.removeClass("dp_selected"),i.addClass("dp_selected"),"days"===n)&&i.hasClass("dp_not_in_month")&&!i.hasClass("dp_disabled")&&J.show(),L?(R="time",V()):(G.focus(),J.hide()),Ft(a),!L&&J.settings.onSelect&&"function"==typeof J.settings.onSelect&&J.settings.onSelect.call(G,o,t+"-"+$(e+1,2)+"-"+$(s,2),a)},o=function(){for(var t="",e=0;e
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Best jQuery Date Time Picker Plugin - Zebra Datepicker - Super Lightweight & Highly Configurable 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 |36 |45 | 46 |37 |44 |The Ultimate jQuery Date Time Picker:
38 |
Zebra Datepickersuper-lightweight and highly-configurable
39 |40 | Download 41 | View on GitHub 42 |
43 |47 | 48 |693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | -------------------------------------------------------------------------------- /examples/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Datepicker/881d1a6023d4d7cd265d9baa5e6420934c721863/examples/close.png -------------------------------------------------------------------------------- /examples/examples.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Tahoma, Helvetica, Arial, sans-serif; 3 | } 4 | 5 | h1 small { 6 | display: block; 7 | font-size: 50%; 8 | color: #666; 9 | margin-top: 0.2em; 10 | } 11 | 12 | .info { 13 | padding: 1em; 14 | background: #fafafa; 15 | } 16 | 17 | .syntaxhighlighter { 18 | padding: .5em 0; 19 | } 20 | 21 | #container { 22 | z-index: 100; 23 | } 24 | 25 | .Zebra_DatePicker .dp_daypicker .myclass { 26 | background: #E8E8E8 url('close.png') no-repeat center center; 27 | text-indent: -9999px; 28 | } 29 | 30 | .bootstrap .Zebra_DatePicker .dp_daypicker td.myclass_disabled { 31 | background: #FFF url('close.png') no-repeat center center; 32 | text-indent: -9999px; 33 | } 34 | 35 | .top { 36 | display: block; 37 | border-bottom: 1px solid #eee; 38 | margin-bottom: 33px; 39 | } 40 | 41 | .top a { 42 | background: #FFF; 43 | position: relative; 44 | top: 8px; 45 | padding-right: 10px; 46 | } 47 | 48 | blockquote.bg-warning.Zebra_Pin { 49 | border-bottom: 1px solid #ccc; 50 | box-shadow: 0 12px 6px -6px rgba(0, 0, 0, .1); 51 | transition: box-shadow .25s linear; 52 | } 53 | 54 | .screenshot { 55 | background: url('themes.png'); 56 | width: 270px; 57 | height: 285px; 58 | margin: 0 auto; 59 | } 60 | 61 | .screenshot-default { 62 | background-position: left -15px; 63 | } 64 | 65 | .screenshot-metallic { 66 | background-position: -270px -15px; 67 | } 68 | 69 | .screenshot-bootstrap { 70 | background-position: -542px -15px; 71 | } -------------------------------------------------------------------------------- /examples/examples.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | 3 | $('#datepicker').Zebra_DatePicker(); 4 | 5 | $('#datepicker-future-tomorrow').Zebra_DatePicker({ 6 | direction: 1 7 | }); 8 | 9 | $('#datepicker-dynamic-interval').Zebra_DatePicker({ 10 | direction: [1, 10] 11 | }); 12 | 13 | $('#datepicker-dates-interval').Zebra_DatePicker({ 14 | direction: ['2012-08-01', '2012-08-12'] 15 | }); 16 | 17 | $('#datepicker-after-date').Zebra_DatePicker({ 18 | direction: ['2012-08-01', false] 19 | }); 20 | 21 | $('#datepicker-disabled-dates').Zebra_DatePicker({ 22 | direction: true, 23 | disabled_dates: ['* * * 0,6'] 24 | }); 25 | 26 | $('#datepicker-range-start').Zebra_DatePicker({ 27 | direction: true, 28 | pair: $('#datepicker-range-end') 29 | }); 30 | 31 | $('#datepicker-range-end').Zebra_DatePicker({ 32 | direction: 1 33 | }); 34 | 35 | $('#datepicker-formats').Zebra_DatePicker({ 36 | format: 'M d, Y' 37 | }); 38 | 39 | $('#datepicker-time').Zebra_DatePicker({ 40 | format: 'Y-m-d H:i' 41 | }); 42 | 43 | $('#datepicker-week-number').Zebra_DatePicker({ 44 | show_week_number: 'Wk' 45 | }); 46 | 47 | $('#datepicker-starting-view').Zebra_DatePicker({ 48 | view: 'years' 49 | }); 50 | 51 | $('#datepicker-partial-date-formats').Zebra_DatePicker({ 52 | format: 'm Y' 53 | }); 54 | 55 | $('#datepicker-custom-classes').Zebra_DatePicker({ 56 | disabled_dates: ['* * * 0,6'], 57 | custom_classes: { 58 | 'myclass': ['* * * 0,6'] 59 | } 60 | }); 61 | 62 | $('#datepicker-on-change').Zebra_DatePicker({ 63 | onChange: function(view, elements) { 64 | if (view === 'days') { 65 | elements.each(function() { 66 | if ($(this).data('date').match(/\-24$/)) 67 | $(this).css({ 68 | background: '#C40000', 69 | color: '#FFF' 70 | }); 71 | }); 72 | } 73 | } 74 | }); 75 | 76 | $('#datepicker-always-visible').Zebra_DatePicker({ 77 | always_visible: $('#container') 78 | }); 79 | 80 | $('#datepicker-rtl-support').Zebra_DatePicker({ 81 | rtl: true 82 | }); 83 | 84 | $('#datepicker-data-attributes').Zebra_DatePicker(); 85 | 86 | setTimeout(function() { 87 | $.Zebra_Pin($('blockquote.bg-warning')); 88 | }, 500); 89 | 90 | }); -------------------------------------------------------------------------------- /examples/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Datepicker/881d1a6023d4d7cd265d9baa5e6420934c721863/examples/favicon.ico -------------------------------------------------------------------------------- /examples/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |49 | 50 |691 | 692 |51 | 52 |689 | 690 |See the examples with the date pickers having the default or the metallic theme.53 | 54 |55 |81 | 82 |56 |77 |57 | Zebra Datepicker is a small, compact and highly configurable date picker / time picker 58 | jQuery plugin, meant to enrich forms by adding the date picker functionality to them. 59 | Zebra Datepicker is a user-friendly and highly configurable date and time picker jQuery plugin. 60 | Its lightweight design makes it easy to implement on any website, and it's compatible with 61 | all major browsers. With a range of customization options, you can easily tailor the plugin 62 | to suit your needs and enhance the functionality of your forms. Whether you're looking for 63 | a simple date time picker or a more advanced one, Zebra Datepicker has you covered. 64 |
65 |66 | This jQuery plugin will automatically add a calendar icon to the indicated input fields 67 | which, when clicked, will open the attached date picker. 68 | This jQuery date time picker plugin will automatically add a calendar icon to the indicated 69 | input fields which, when clicked, will open the attached date time picker. 70 |
71 |72 | Users can easily jump between months and years due to the date pickers intuitive interface. 73 | The selected date will be entered in the input field using the date format of choice, 74 | configurable in the date picker's options. 75 |
76 |78 | 79 |80 |
83 | 84 |85 |107 | 108 |86 | 1. Default initialization95 |
87 | 2. Allow future dates only starting one day in the future
88 | 3. Allow dates from a dynamic interval
89 | 4. Allow dates from an interval between 2 dates
90 | 5. Allow only dates that come after a certain date
91 | 6. Disable dates
92 | 7. Date ranges (sort of)
93 | 8. Date formats
94 |96 | 9. Enabling the time picker106 |
97 | 10. Partial date formats
98 | 11. Showing week numbers
99 | 12. Changing the starting view
100 | 13. Custom classes
101 | 14. Handling the "onChange" event
102 | 15. Always-visible date pickers
103 | 16. RTL support
104 | 17. Data attributes
105 |
109 | 110 | 111 | 112 |113 | 114 | Note that the
118 | 119 |Bootstrap
theme does not actually require Twitter Bootstrap 115 | CSS framework to be present!
Its name comes from the fact that it borrows the color scheme from 116 | Twitter Bootstrap's default theme. 117 |1. Default initialization
120 | 121 |122 | All dates are selectable, no restrictions.
125 | 126 |
123 | There are a lot of things that can be configured! 124 |127 | $('#datepicker').Zebra_DatePicker(); 128 |129 | 130 |131 |137 | 138 | 139 |132 |136 |133 | 134 |135 |140 | ▲ To the top 141 |142 | 143 | 144 | 145 |2. Allow future dates only, starting one day in the future
146 | 147 |148 | All past dates, including today, are disabled.
151 | 152 |
149 | Read more about using the direction property. 150 |153 | $('#datepicker').Zebra_DatePicker({ 154 | direction: 1 155 | }); 156 |157 | 158 |159 |165 | 166 | 167 |160 |164 |161 | 162 |163 |168 | ▲ To the top 169 |170 | 171 | 172 | 173 |3. Allow dates from a dynamic interval
174 | 175 |176 | The selectable dates are in the interval starting tomorrow and ending 10 days after that.
179 | 180 |
177 | Read more about using the direction property. 178 |181 | $('#datepicker').Zebra_DatePicker({ 182 | direction: [1, 10] 183 | }); 184 |185 | 186 |187 |193 | 194 | 195 |188 |192 |189 | 190 |191 |196 | ▲ To the top 197 |198 | 199 | 200 | 201 |4. Allow dates from an interval between 2 dates
202 | 203 |204 | Dates in the
207 | 208 |direction
property have to be written in the date picker's date format.
205 | Read more about using the direction property. 206 |209 | $('#datepicker').Zebra_DatePicker({ 210 | direction: ['2012-08-01', '2012-08-12'] 211 | }); 212 |213 | 214 |215 |221 | 222 | 223 |216 |220 |217 | 218 |219 |224 | ▲ To the top 225 |226 | 227 | 228 | 229 |5. Allow only dates that come after a certain date
230 | 231 |232 | Dates in the
235 | 236 |direction
property have to be written in the date picker's date format.
233 | Read more about using the direction property. 234 |237 | $('#datepicker').Zebra_DatePicker({ 238 | direction: ['2012-08-01', false] 239 | }); 240 |241 | 242 |243 |249 | 250 | 251 |244 |248 |245 | 246 |247 |252 | ▲ To the top 253 |254 | 255 | 256 | 257 |6. Disable dates
258 | 259 |260 | Allow future dates only including the current day.
265 | 266 |
261 | All past dates are disabled.
262 | Saturday and Sundays are disabled.
263 | Read more about using the direction property and about disabling dates. 264 |267 | $('#datepicker').Zebra_DatePicker({ 268 | direction: true, 269 | disabled_dates: ['* * * 0,6'] // all days, all months, all years as long 270 | // as the weekday is 0 or 6 (Sunday or Saturday) 271 | }); 272 |273 | 274 |275 |281 | 282 | 283 |276 |280 |277 | 278 |279 |284 | ▲ To the top 285 |286 | 287 | 288 | 289 |7. Date ranges (sort of)
290 | 291 |The second date picker's starting date is the value of the first date picker + 1
292 | 293 |294 | $('#datepicker-range-start').Zebra_DatePicker({ 295 | direction: true, 296 | pair: $('#datepicker-range-end') 297 | }); 298 | 299 | $('#datepicker-range-end').Zebra_DatePicker({ 300 | direction: 1 301 | }); 302 |303 | 304 |305 |314 | 315 | 316 |306 |313 |307 | 308 |309 |310 | 311 |312 |317 | ▲ To the top 318 |319 | 320 | 321 | 322 |8. Date formats
323 | 324 |325 | Accepts the following characters for date formatting:
342 | 343 |d
,D
,j
, 326 |l
,N
,w
,S
,F
,m
, 327 |M
,n
,Y
,y
,h
,H
, 328 |g
,G
,i
,s
,a
,A
, 329 | borrowing the syntax from PHP's date 330 | function.
331 | 332 | Ifformat
property contains time-related characters (g
,G
, 333 |h
,H
,i
,s
,a
,A
), 334 | the time picker will be automatically enabled.
335 | 336 | Note that when setting a date format without days (d
,j
), the users will 337 | be able to select only years and months, and when setting a format without months and days 338 | (F
,m
,M
,n
,t
,d
, 339 |j
), the users will be able to select only years. Similarly, setting a format that 340 | contains only time-related characters, will result in users being able to only select time. 341 |344 | $('#datepicker').Zebra_DatePicker({ 345 | format: 'M d, Y' 346 | }); 347 |348 | 349 |350 |356 | 357 | 358 |351 |355 |352 | 353 |354 |359 | ▲ To the top 360 |361 | 362 | 363 | 364 |9. Enabling the time picker
365 | 366 |367 | If
371 | 372 |format
property contains time-related characters (g
,G
, 368 |h
,H
,i
,s
,a
,A
), 369 | the time picker will be automatically enabled. 370 |373 | $('#datepicker').Zebra_DatePicker({ 374 | format: 'Y-m-d H:i' 375 | }); 376 |377 | 378 |379 |385 | 386 | 387 |380 |384 |381 | 382 |383 |388 | ▲ To the top 389 |390 | 391 | 392 | 393 |10. Partial date formats
394 | 395 |396 | The date picker will not show views that are not present in format.
401 | 402 |
397 | 398 | In the example below, the date picker will never get to theday
view as there is no 399 |day
-related character in the date's format. 400 |403 | $('#datepicker').Zebra_DatePicker({ 404 | format: 'm Y', 405 | }); 406 |407 | 408 |409 |415 | 416 | 417 |410 |414 |411 | 412 |413 |418 | ▲ To the top 419 |420 | 421 | 422 | 423 |11. Showing week numbers
424 | 425 |426 | Show the ISO 8601 week number. 427 |
428 | 429 |430 | $('#datepicker').Zebra_DatePicker({ 431 | show_week_number: 'Wk' 432 | }); 433 |434 | 435 |436 |442 | 443 | 444 |437 |441 |438 | 439 |440 |445 | ▲ To the top 446 |447 | 448 | 449 | 450 |12. Changing the starting view
451 | 452 |453 | Start with the
466 | 467 |years
view, recommended for when users need to select their birth 454 | date.
455 | 456 | You can always switch between views by clicking on caption in the date picker's header, between 457 | theprevious
andnext
buttons!
458 | 459 | Note that the date picker is always cyclingdays -> months -> years
when clicking 460 | on the date picker's header, andyears -> months -> days
when selecting dates (skipping 461 | the views that are missing because of the date's format)
462 | 463 | Also note that the value of the view property may be overridden if the date's format requires so! (i.e.days
for the view property makes no sense if the date format doesn't allow the selection of days) 464 | 465 |468 | $('#datepicker').Zebra_DatePicker({ 469 | view: 'years' 470 | }); 471 |472 | 473 |474 |480 | 481 | 482 |475 |479 |476 | 477 |478 |483 | ▲ To the top 484 |485 | 486 | 487 | 488 |13. Custom classes
489 | 490 |491 | Disable weekends and apply a custom class to Saturdays and Sundays. 492 |
493 | 494 |495 | $('#datepicker').Zebra_DatePicker({ 496 | disabled_dates: ['* * * 0,6'], 497 | custom_classes: { 498 | 'myclass': ['* * * 0,6'] 499 | } 500 | }); 501 |502 | 503 |504 |510 | 511 | 512 |505 |509 |506 | 507 |508 |513 | ▲ To the top 514 |515 | 516 | 517 | 518 |14. Handling the "onChange" event
519 | 520 |521 | If a callback function is attached to the
525 | 526 |onChange
event, it will be called whenever 522 | the user changes the view (days/months/years), as well as when the user navigates by clicking on 523 | the next/previous icons in any of the views. 524 |The callback function takes two arguments:
527 | 528 |529 |
537 | 538 |- 530 | the view (
532 |days
,months
oryears
) 531 |- 533 | the active elements (not disabled) in that view, as jQuery elements, allowing for 534 | easy customization and interaction with particular cells in the date picker's view 535 |
536 |539 | $('#datepicker').Zebra_DatePicker({ 540 | 541 | // execute a function whenever the user changes the view (days/months/years), 542 | // as well as when the user navigates by clicking on the "next"/"previous" 543 | // icons in any of the views 544 | onChange: function(view, elements) { 545 | 546 | // on the "days" view... 547 | if (view == 'days') { 548 | 549 | // iterate through the active elements in the view 550 | elements.each(function() { 551 | 552 | // to simplify searching for particular dates, each element gets a 553 | // "date" data attribute which is the form of: 554 | // - YYYY-MM-DD for elements in the "days" view 555 | // - YYYY-MM for elements in the "months" view 556 | // - YYYY for elements in the "years" view 557 | 558 | // so, because we're on a "days" view, 559 | // let's find the 24th day using a regular expression 560 | // (notice that this will apply to every 24th day 561 | // of every month of every year) 562 | if ($(this).data('date').match(/\-24$/)) 563 | 564 | // and highlight it! 565 | $(this).css({ 566 | background: '#C40000', 567 | color: '#FFF' 568 | }); 569 | 570 | }); 571 | 572 | } 573 | 574 | } 575 | }); 576 |577 | 578 |579 |585 | 586 | 587 |580 |584 |581 | 582 |583 |588 | ▲ To the top 589 |590 | 591 | 592 | 593 |15. Always-visible date pickers
594 | 595 |596 | Set the
600 | 601 |always_visible
property's value to a jQuery element which will act as a 597 | container for the date picker.
Notice that in this case the element the date picker is attached 598 | to has no icon. 599 |602 | $('#datepicker').Zebra_DatePicker({ 603 | always_visible: $('#container') 604 | }); 605 |606 | 607 | 608 | 609 |610 |616 | 617 | 618 |611 |615 |612 | 613 |614 |619 | ▲ To the top 620 |621 | 622 | 623 | 624 |16. RTL support
625 | 626 |627 | Set the
630 | 631 |rtl
property totrue
to have the current language drawn from 628 | right to left. 629 |632 | $('#datepicker').Zebra_DatePicker({ 633 | rtl: true 634 | }); 635 |636 | 637 |638 |644 | 645 | 646 |639 |643 |640 | 641 |642 |647 | ▲ To the top 648 |649 | 650 | 651 | 652 |17. Data attributes
653 | 654 |655 | All the properties of the date picker can also be set via
664 | 665 |data-attributes
.
656 | 657 | All you have to do is take any property described in the configuration section and 658 | prefix it withdata-zdp_
.
659 | 660 | Remember that if the value of the property is an array, you will have to use double 661 | quotes inside the square brackets and single quotes around the attribute, like in 662 | the example below: 663 |666 | <input type="text" id="datepicker" data-zdp_direction="1" data-zdp_disabled_dates='["* * * 0,6"]'> 667 |668 |669 | $('#datepicker').Zebra_DatePicker(); 670 |671 | 672 |673 |679 | 680 |674 |678 |675 | 676 |677 |681 | ▲ To the top 682 |683 | 684 |copyright © 2011 - stefan gabos
685 | 686 |
687 | 688 |Best jQuery Date Time Picker Plugin - Zebra Datepicker - Super Lightweight & Highly Configurable 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 |36 |45 | 46 |37 |44 |The Ultimate jQuery Date Time Picker:
38 |
Zebra Datepickersuper-lightweight and highly-configurable
39 |40 | Download 41 | View on GitHub 42 |
43 |47 | 48 |687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | -------------------------------------------------------------------------------- /examples/metallic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |49 | 50 |685 | 686 |51 | 52 |683 | 684 |See the examples with the date pickers having the metallic or the bootstrap theme.53 | 54 |55 |81 | 82 |56 |77 |57 | Zebra Datepicker is a small, compact and highly configurable date picker / time picker 58 | jQuery plugin, meant to enrich forms by adding the date picker functionality to them. 59 | Zebra Datepicker is a user-friendly and highly configurable date and time picker jQuery plugin. 60 | Its lightweight design makes it easy to implement on any website, and it's compatible with 61 | all major browsers. With a range of customization options, you can easily tailor the plugin 62 | to suit your needs and enhance the functionality of your forms. Whether you're looking for 63 | a simple date time picker or a more advanced one, Zebra Datepicker has you covered. 64 |
65 |66 | This jQuery plugin will automatically add a calendar icon to the indicated input fields 67 | which, when clicked, will open the attached date picker. 68 | This jQuery date time picker plugin will automatically add a calendar icon to the indicated 69 | input fields which, when clicked, will open the attached date time picker. 70 |
71 |72 | Users can easily jump between months and years due to the date pickers intuitive interface. 73 | The selected date will be entered in the input field using the date format of choice, 74 | configurable in the date picker's options. 75 |
76 |78 | 79 |80 |
83 | 84 |85 |107 | 108 | 109 |86 | 1. Default initialization95 |
87 | 2. Allow future dates only starting one day in the future
88 | 3. Allow dates from a dynamic interval
89 | 4. Allow dates from an interval between 2 dates
90 | 5. Allow only dates that come after a certain date
91 | 6. Disable dates
92 | 7. Date ranges (sort of)
93 | 8. Date formats
94 |96 | 9. Enabling the time picker106 |
97 | 10. Partial date formats
98 | 11. Showing week numbers
99 | 12. Changing the starting view
100 | 13. Custom classes
101 | 14. Handling the "onChange" event
102 | 15. Always-visible date pickers
103 | 16. RTL support
104 | 17. Data attributes
105 |
110 | 111 | 112 | 113 |1. Default initialization
114 | 115 |116 | All dates are selectable, no restrictions.
119 | 120 |
117 | There are a lot of things that can be configured! 118 |121 | $('#datepicker').Zebra_DatePicker(); 122 |123 | 124 |125 |131 | 132 | 133 |126 |130 |127 | 128 |129 |134 | ▲ To the top 135 |136 | 137 | 138 | 139 |2. Allow future dates only, starting one day in the future
140 | 141 |142 | All past dates, including today, are disabled.
145 | 146 |
143 | Read more about using the direction property. 144 |147 | $('#datepicker').Zebra_DatePicker({ 148 | direction: 1 149 | }); 150 |151 | 152 |153 |159 | 160 | 161 |154 |158 |155 | 156 |157 |162 | ▲ To the top 163 |164 | 165 | 166 | 167 |3. Allow dates from a dynamic interval
168 | 169 |170 | The selectable dates are in the interval starting tomorrow and ending 10 days after that.
173 | 174 |
171 | Read more about using the direction property. 172 |175 | $('#datepicker').Zebra_DatePicker({ 176 | direction: [1, 10] 177 | }); 178 |179 | 180 |181 |187 | 188 | 189 |182 |186 |183 | 184 |185 |190 | ▲ To the top 191 |192 | 193 | 194 | 195 |4. Allow dates from an interval between 2 dates
196 | 197 |198 | Dates in the
201 | 202 |direction
property have to be written in the date picker's date format.
199 | Read more about using the direction property. 200 |203 | $('#datepicker').Zebra_DatePicker({ 204 | direction: ['2012-08-01', '2012-08-12'] 205 | }); 206 |207 | 208 |209 |215 | 216 | 217 |210 |214 |211 | 212 |213 |218 | ▲ To the top 219 |220 | 221 | 222 | 223 |5. Allow only dates that come after a certain date
224 | 225 |226 | Dates in the
229 | 230 |direction
property have to be written in the date picker's date format.
227 | Read more about using the direction property. 228 |231 | $('#datepicker').Zebra_DatePicker({ 232 | direction: ['2012-08-01', false] 233 | }); 234 |235 | 236 |237 |243 | 244 | 245 |238 |242 |239 | 240 |241 |246 | ▲ To the top 247 |248 | 249 | 250 | 251 |6. Disable dates
252 | 253 |254 | Allow future dates only including the current day.
259 | 260 |
255 | All past dates are disabled.
256 | Saturday and Sundays are disabled.
257 | Read more about using the direction property and about disabling dates. 258 |261 | $('#datepicker').Zebra_DatePicker({ 262 | direction: true, 263 | disabled_dates: ['* * * 0,6'] // all days, all months, all years as long 264 | // as the weekday is 0 or 6 (Sunday or Saturday) 265 | }); 266 |267 | 268 |269 |275 | 276 | 277 |270 |274 |271 | 272 |273 |278 | ▲ To the top 279 |280 | 281 | 282 | 283 |7. Date ranges (sort of)
284 | 285 |The second date picker's starting date is the value of the first date picker + 1
286 | 287 |288 | $('#datepicker-range-start').Zebra_DatePicker({ 289 | direction: true, 290 | pair: $('#datepicker-range-end') 291 | }); 292 | 293 | $('#datepicker-range-end').Zebra_DatePicker({ 294 | direction: 1 295 | }); 296 |297 | 298 |299 |308 | 309 | 310 |300 |307 |301 | 302 |303 |304 | 305 |306 |311 | ▲ To the top 312 |313 | 314 | 315 | 316 |8. Date formats
317 | 318 |319 | Accepts the following characters for date formatting:
336 | 337 |d
,D
,j
, 320 |l
,N
,w
,S
,F
,m
, 321 |M
,n
,Y
,y
,h
,H
, 322 |g
,G
,i
,s
,a
,A
, 323 | borrowing the syntax from PHP's date 324 | function.
325 | 326 | Ifformat
property contains time-related characters (g
,G
, 327 |h
,H
,i
,s
,a
,A
), 328 | the time picker will be automatically enabled.
329 | 330 | Note that when setting a date format without days (d
,j
), the users will 331 | be able to select only years and months, and when setting a format without months and days 332 | (F
,m
,M
,n
,t
,d
, 333 |j
), the users will be able to select only years. Similarly, setting a format that 334 | contains only time-related characters, will result in users being able to only select time. 335 |338 | $('#datepicker').Zebra_DatePicker({ 339 | format: 'M d, Y' 340 | }); 341 |342 | 343 |344 |350 | 351 | 352 |345 |349 |346 | 347 |348 |353 | ▲ To the top 354 |355 | 356 | 357 | 358 |9. Enabling the time picker
359 | 360 |361 | If
365 | 366 |format
property contains time-related characters (g
,G
, 362 |h
,H
,i
,s
,a
,A
), 363 | the time picker will be automatically enabled. 364 |367 | $('#datepicker').Zebra_DatePicker({ 368 | format: 'Y-m-d H:i' 369 | }); 370 |371 | 372 |373 |379 | 380 | 381 |374 |378 |375 | 376 |377 |382 | ▲ To the top 383 |384 | 385 | 386 | 387 |10. Partial date formats
388 | 389 |390 | The date picker will not show views that are not present in format.
395 | 396 |
391 | 392 | In the example below, the date picker will never get to theday
view as there is no 393 |day
-related character in the date's format. 394 |397 | $('#datepicker').Zebra_DatePicker({ 398 | format: 'm Y', 399 | }); 400 |401 | 402 |403 |409 | 410 | 411 |404 |408 |405 | 406 |407 |412 | ▲ To the top 413 |414 | 415 | 416 | 417 |11. Showing week numbers
418 | 419 |420 | Show the ISO 8601 week number. 421 |
422 | 423 |424 | $('#datepicker').Zebra_DatePicker({ 425 | show_week_number: 'Wk' 426 | }); 427 |428 | 429 |430 |436 | 437 | 438 |431 |435 |432 | 433 |434 |439 | ▲ To the top 440 |441 | 442 | 443 | 444 |12. Changing the starting view
445 | 446 |447 | Start with the
460 | 461 |years
view, recommended for when users need to select their birth 448 | date.
449 | 450 | You can always switch between views by clicking on caption in the date picker's header, between 451 | theprevious
andnext
buttons!
452 | 453 | Note that the date picker is always cyclingdays -> months -> years
when clicking 454 | on the date picker's header, andyears -> months -> days
when selecting dates (skipping 455 | the views that are missing because of the date's format)
456 | 457 | Also note that the value of the view property may be overridden if the date's format requires so! (i.e.days
for the view property makes no sense if the date format doesn't allow the selection of days) 458 | 459 |462 | $('#datepicker').Zebra_DatePicker({ 463 | view: 'years' 464 | }); 465 |466 | 467 |468 |474 | 475 | 476 |469 |473 |470 | 471 |472 |477 | ▲ To the top 478 |479 | 480 | 481 | 482 |13. Custom classes
483 | 484 |485 | Disable weekends and apply a custom class to Saturdays and Sundays. 486 |
487 | 488 |489 | $('#datepicker').Zebra_DatePicker({ 490 | disabled_dates: ['* * * 0,6'], 491 | custom_classes: { 492 | 'myclass': ['* * * 0,6'] 493 | } 494 | }); 495 |496 | 497 |498 |504 | 505 | 506 |499 |503 |500 | 501 |502 |507 | ▲ To the top 508 |509 | 510 | 511 | 512 |14. Handling the "onChange" event
513 | 514 |515 | If a callback function is attached to the
519 | 520 |onChange
event, it will be called whenever 516 | the user changes the view (days/months/years), as well as when the user navigates by clicking on 517 | the next/previous icons in any of the views. 518 |The callback function takes two arguments:
521 | 522 |523 |
531 | 532 |- 524 | the view (
526 |days
,months
oryears
) 525 |- 527 | the active elements (not disabled) in that view, as jQuery elements, allowing for 528 | easy customization and interaction with particular cells in the date picker's view 529 |
530 |533 | $('#datepicker').Zebra_DatePicker({ 534 | 535 | // execute a function whenever the user changes the view (days/months/years), 536 | // as well as when the user navigates by clicking on the "next"/"previous" 537 | // icons in any of the views 538 | onChange: function(view, elements) { 539 | 540 | // on the "days" view... 541 | if (view == 'days') { 542 | 543 | // iterate through the active elements in the view 544 | elements.each(function() { 545 | 546 | // to simplify searching for particular dates, each element gets a 547 | // "date" data attribute which is the form of: 548 | // - YYYY-MM-DD for elements in the "days" view 549 | // - YYYY-MM for elements in the "months" view 550 | // - YYYY for elements in the "years" view 551 | 552 | // so, because we're on a "days" view, 553 | // let's find the 24th day using a regular expression 554 | // (notice that this will apply to every 24th day 555 | // of every month of every year) 556 | if ($(this).data('date').match(/\-24$/)) 557 | 558 | // and highlight it! 559 | $(this).css({ 560 | background: '#C40000', 561 | color: '#FFF' 562 | }); 563 | 564 | }); 565 | 566 | } 567 | 568 | } 569 | }); 570 |571 | 572 |573 |579 | 580 | 581 |574 |578 |575 | 576 |577 |582 | ▲ To the top 583 |584 | 585 | 586 | 587 |15. Always-visible date pickers
588 | 589 |590 | Set the
594 | 595 |always_visible
property's value to a jQuery element which will act as a 591 | container for the date picker.
Notice that in this case the element the date picker is attached 592 | to has no icon. 593 |596 | $('#datepicker').Zebra_DatePicker({ 597 | always_visible: $('#container') 598 | }); 599 |600 | 601 | 602 | 603 |604 |610 | 611 | 612 |605 |609 |606 | 607 |608 |613 | ▲ To the top 614 |615 | 616 | 617 | 618 |16. RTL support
619 | 620 |621 | Set the
624 | 625 |rtl
property totrue
to have the current language drawn from 622 | right to left. 623 |626 | $('#datepicker').Zebra_DatePicker({ 627 | rtl: true 628 | }); 629 |630 | 631 |632 |638 | 639 | 640 |633 |637 |634 | 635 |636 |641 | ▲ To the top 642 |643 | 644 | 645 | 646 |17. Data attributes
647 | 648 |649 | All the properties of the date picker can also be set via
658 | 659 |data-attributes
.
650 | 651 | All you have to do is take any property described in the configuration section and 652 | prefix it withdata-zdp_
.
653 | 654 | Remember that if the value of the property is an array, you will have to use double 655 | quotes inside the square brackets and single quotes around the attribute, like in 656 | the example below: 657 |660 | <input type="text" id="datepicker" data-zdp_direction="1" data-zdp_disabled_dates='["* * * 0,6"]'> 661 |662 |663 | $('#datepicker').Zebra_DatePicker(); 664 |665 | 666 |667 |673 | 674 |668 |672 |669 | 670 |671 |675 | ▲ To the top 676 |677 | 678 |copyright © 2011 - stefan gabos
679 | 680 |
681 | 682 |Best jQuery Date Time Picker Plugin - Zebra Datepicker - Super Lightweight & Highly Configurable 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 |36 |45 | 46 |37 |44 |The Ultimate jQuery Date Time Picker:
38 |
Zebra Datepickersuper-lightweight and highly-configurable
39 |40 | Download 41 | View on GitHub 42 |
43 |47 | 48 |687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | --------------------------------------------------------------------------------49 | 50 |685 | 686 |51 | 52 |683 | 684 |See the examples with the date pickers having the default or the bootstrap theme.53 | 54 |55 |81 | 82 |56 |77 |57 | Zebra Datepicker is a small, compact and highly configurable date picker / time picker 58 | jQuery plugin, meant to enrich forms by adding the date picker functionality to them. 59 | Zebra Datepicker is a user-friendly and highly configurable date and time picker jQuery plugin. 60 | Its lightweight design makes it easy to implement on any website, and it's compatible with 61 | all major browsers. With a range of customization options, you can easily tailor the plugin 62 | to suit your needs and enhance the functionality of your forms. Whether you're looking for 63 | a simple date time picker or a more advanced one, Zebra Datepicker has you covered. 64 |
65 |66 | This jQuery plugin will automatically add a calendar icon to the indicated input fields 67 | which, when clicked, will open the attached date picker. 68 | This jQuery date time picker plugin will automatically add a calendar icon to the indicated 69 | input fields which, when clicked, will open the attached date time picker. 70 |
71 |72 | Users can easily jump between months and years due to the date pickers intuitive interface. 73 | The selected date will be entered in the input field using the date format of choice, 74 | configurable in the date picker's options. 75 |
76 |78 | 79 |80 |
83 | 84 |85 |107 | 108 | 109 |86 | 1. Default initialization95 |
87 | 2. Allow future dates only starting one day in the future
88 | 3. Allow dates from a dynamic interval
89 | 4. Allow dates from an interval between 2 dates
90 | 5. Allow only dates that come after a certain date
91 | 6. Disable dates
92 | 7. Date ranges (sort of)
93 | 8. Date formats
94 |96 | 9. Enabling the time picker106 |
97 | 10. Partial date formats
98 | 11. Showing week numbers
99 | 12. Changing the starting view
100 | 13. Custom classes
101 | 14. Handling the "onChange" event
102 | 15. Always-visible date pickers
103 | 16. RTL support
104 | 17. Data attributes
105 |
110 | 111 | 112 | 113 |1. Default initialization
114 | 115 |116 | All dates are selectable, no restrictions.
119 | 120 |
117 | There are a lot of things that can be configured! 118 |121 | $('#datepicker').Zebra_DatePicker(); 122 |123 | 124 |125 |131 | 132 | 133 |126 |130 |127 | 128 |129 |134 | ▲ To the top 135 |136 | 137 | 138 | 139 |2. Allow future dates only, starting one day in the future
140 | 141 |142 | All past dates, including today, are disabled.
145 | 146 |
143 | Read more about using the direction property. 144 |147 | $('#datepicker').Zebra_DatePicker({ 148 | direction: 1 149 | }); 150 |151 | 152 |153 |159 | 160 | 161 |154 |158 |155 | 156 |157 |162 | ▲ To the top 163 |164 | 165 | 166 | 167 |3. Allow dates from a dynamic interval
168 | 169 |170 | The selectable dates are in the interval starting tomorrow and ending 10 days after that.
173 | 174 |
171 | Read more about using the direction property. 172 |175 | $('#datepicker').Zebra_DatePicker({ 176 | direction: [1, 10] 177 | }); 178 |179 | 180 |181 |187 | 188 | 189 |182 |186 |183 | 184 |185 |190 | ▲ To the top 191 |192 | 193 | 194 | 195 |4. Allow dates from an interval between 2 dates
196 | 197 |198 | Dates in the
201 | 202 |direction
property have to be written in the date picker's date format.
199 | Read more about using the direction property. 200 |203 | $('#datepicker').Zebra_DatePicker({ 204 | direction: ['2012-08-01', '2012-08-12'] 205 | }); 206 |207 | 208 |209 |215 | 216 | 217 |210 |214 |211 | 212 |213 |218 | ▲ To the top 219 |220 | 221 | 222 | 223 |5. Allow only dates that come after a certain date
224 | 225 |226 | Dates in the
229 | 230 |direction
property have to be written in the date picker's date format.
227 | Read more about using the direction property. 228 |231 | $('#datepicker').Zebra_DatePicker({ 232 | direction: ['2012-08-01', false] 233 | }); 234 |235 | 236 |237 |243 | 244 | 245 |238 |242 |239 | 240 |241 |246 | ▲ To the top 247 |248 | 249 | 250 | 251 |6. Disable dates
252 | 253 |254 | Allow future dates only including the current day.
259 | 260 |
255 | All past dates are disabled.
256 | Saturday and Sundays are disabled.
257 | Read more about using the direction property and about disabling dates. 258 |261 | $('#datepicker').Zebra_DatePicker({ 262 | direction: true, 263 | disabled_dates: ['* * * 0,6'] // all days, all months, all years as long 264 | // as the weekday is 0 or 6 (Sunday or Saturday) 265 | }); 266 |267 | 268 |269 |275 | 276 | 277 |270 |274 |271 | 272 |273 |278 | ▲ To the top 279 |280 | 281 | 282 | 283 |7. Date ranges (sort of)
284 | 285 |The second date picker's starting date is the value of the first date picker + 1
286 | 287 |288 | $('#datepicker-range-start').Zebra_DatePicker({ 289 | direction: true, 290 | pair: $('#datepicker-range-end') 291 | }); 292 | 293 | $('#datepicker-range-end').Zebra_DatePicker({ 294 | direction: 1 295 | }); 296 |297 | 298 |299 |308 | 309 | 310 |300 |307 |301 | 302 |303 |304 | 305 |306 |311 | ▲ To the top 312 |313 | 314 | 315 | 316 |8. Date formats
317 | 318 |319 | Accepts the following characters for date formatting:
336 | 337 |d
,D
,j
, 320 |l
,N
,w
,S
,F
,m
, 321 |M
,n
,Y
,y
,h
,H
, 322 |g
,G
,i
,s
,a
,A
, 323 | borrowing the syntax from PHP's date 324 | function.
325 | 326 | Ifformat
property contains time-related characters (g
,G
, 327 |h
,H
,i
,s
,a
,A
), 328 | the time picker will be automatically enabled.
329 | 330 | Note that when setting a date format without days (d
,j
), the users will 331 | be able to select only years and months, and when setting a format without months and days 332 | (F
,m
,M
,n
,t
,d
, 333 |j
), the users will be able to select only years. Similarly, setting a format that 334 | contains only time-related characters, will result in users being able to only select time. 335 |338 | $('#datepicker').Zebra_DatePicker({ 339 | format: 'M d, Y' 340 | }); 341 |342 | 343 |344 |350 | 351 | 352 |345 |349 |346 | 347 |348 |353 | ▲ To the top 354 |355 | 356 | 357 | 358 |9. Enabling the time picker
359 | 360 |361 | If
365 | 366 |format
property contains time-related characters (g
,G
, 362 |h
,H
,i
,s
,a
,A
), 363 | the time picker will be automatically enabled. 364 |367 | $('#datepicker').Zebra_DatePicker({ 368 | format: 'Y-m-d H:i' 369 | }); 370 |371 | 372 |373 |379 | 380 | 381 |374 |378 |375 | 376 |377 |382 | ▲ To the top 383 |384 | 385 | 386 | 387 |10. Partial date formats
388 | 389 |390 | The date picker will not show views that are not present in format.
395 | 396 |
391 | 392 | In the example below, the date picker will never get to theday
view as there is no 393 |day
-related character in the date's format. 394 |397 | $('#datepicker').Zebra_DatePicker({ 398 | format: 'm Y', 399 | }); 400 |401 | 402 |403 |409 | 410 | 411 |404 |408 |405 | 406 |407 |412 | ▲ To the top 413 |414 | 415 | 416 | 417 |11. Showing week numbers
418 | 419 |420 | Show the ISO 8601 week number. 421 |
422 | 423 |424 | $('#datepicker').Zebra_DatePicker({ 425 | show_week_number: 'Wk' 426 | }); 427 |428 | 429 |430 |436 | 437 | 438 |431 |435 |432 | 433 |434 |439 | ▲ To the top 440 |441 | 442 | 443 | 444 |12. Changing the starting view
445 | 446 |447 | Start with the
460 | 461 |years
view, recommended for when users need to select their birth 448 | date.
449 | 450 | You can always switch between views by clicking on caption in the date picker's header, between 451 | theprevious
andnext
buttons!
452 | 453 | Note that the date picker is always cyclingdays -> months -> years
when clicking 454 | on the date picker's header, andyears -> months -> days
when selecting dates (skipping 455 | the views that are missing because of the date's format)
456 | 457 | Also note that the value of the view property may be overridden if the date's format requires so! (i.e.days
for the view property makes no sense if the date format doesn't allow the selection of days) 458 | 459 |462 | $('#datepicker').Zebra_DatePicker({ 463 | view: 'years' 464 | }); 465 |466 | 467 |468 |474 | 475 | 476 |469 |473 |470 | 471 |472 |477 | ▲ To the top 478 |479 | 480 | 481 | 482 |13. Custom classes
483 | 484 |485 | Disable weekends and apply a custom class to Saturdays and Sundays. 486 |
487 | 488 |489 | $('#datepicker').Zebra_DatePicker({ 490 | disabled_dates: ['* * * 0,6'], 491 | custom_classes: { 492 | 'myclass': ['* * * 0,6'] 493 | } 494 | }); 495 |496 | 497 |498 |504 | 505 | 506 |499 |503 |500 | 501 |502 |507 | ▲ To the top 508 |509 | 510 | 511 | 512 |14. Handling the "onChange" event
513 | 514 |515 | If a callback function is attached to the
519 | 520 |onChange
event, it will be called whenever 516 | the user changes the view (days/months/years), as well as when the user navigates by clicking on 517 | the next/previous icons in any of the views. 518 |The callback function takes two arguments:
521 | 522 |523 |
531 | 532 |- 524 | the view (
526 |days
,months
oryears
) 525 |- 527 | the active elements (not disabled) in that view, as jQuery elements, allowing for 528 | easy customization and interaction with particular cells in the date picker's view 529 |
530 |533 | $('#datepicker').Zebra_DatePicker({ 534 | 535 | // execute a function whenever the user changes the view (days/months/years), 536 | // as well as when the user navigates by clicking on the "next"/"previous" 537 | // icons in any of the views 538 | onChange: function(view, elements) { 539 | 540 | // on the "days" view... 541 | if (view == 'days') { 542 | 543 | // iterate through the active elements in the view 544 | elements.each(function() { 545 | 546 | // to simplify searching for particular dates, each element gets a 547 | // "date" data attribute which is the form of: 548 | // - YYYY-MM-DD for elements in the "days" view 549 | // - YYYY-MM for elements in the "months" view 550 | // - YYYY for elements in the "years" view 551 | 552 | // so, because we're on a "days" view, 553 | // let's find the 24th day using a regular expression 554 | // (notice that this will apply to every 24th day 555 | // of every month of every year) 556 | if ($(this).data('date').match(/\-24$/)) 557 | 558 | // and highlight it! 559 | $(this).css({ 560 | background: '#C40000', 561 | color: '#FFF' 562 | }); 563 | 564 | }); 565 | 566 | } 567 | 568 | } 569 | }); 570 |571 | 572 |573 |579 | 580 | 581 |574 |578 |575 | 576 |577 |582 | ▲ To the top 583 |584 | 585 | 586 | 587 |15. Always-visible date pickers
588 | 589 |590 | Set the
594 | 595 |always_visible
property's value to a jQuery element which will act as a 591 | container for the date picker.
Notice that in this case the element the date picker is attached 592 | to has no icon. 593 |596 | $('#datepicker').Zebra_DatePicker({ 597 | always_visible: $('#container') 598 | }); 599 |600 | 601 | 602 | 603 |604 |610 | 611 | 612 |605 |609 |606 | 607 |608 |613 | ▲ To the top 614 |615 | 616 | 617 | 618 |16. RTL support
619 | 620 |621 | Set the
624 | 625 |rtl
property totrue
to have the current language drawn from 622 | right to left. 623 |626 | $('#datepicker').Zebra_DatePicker({ 627 | rtl: true 628 | }); 629 |630 | 631 |632 |638 | 639 | 640 |633 |637 |634 | 635 |636 |641 | ▲ To the top 642 |643 | 644 | 645 | 646 |17. Data attributes
647 | 648 |649 | All the properties of the date picker can also be set via
658 | 659 |data-attributes
.
650 | 651 | All you have to do is take any property described in the configuration section and 652 | prefix it withdata-zdp_
.
653 | 654 | Remember that if the value of the property is an array, you will have to use double 655 | quotes inside the square brackets and single quotes around the attribute, like in 656 | the example below: 657 |660 | <input type="text" id="datepicker" data-zdp_direction="1" data-zdp_disabled_dates='["* * * 0,6"]'> 661 |662 |663 | $('#datepicker').Zebra_DatePicker(); 664 |665 | 666 |667 |673 | 674 |668 |672 |669 | 670 |671 |675 | ▲ To the top 676 |677 | 678 |copyright © 2011 - stefan gabos
679 | 680 |
681 | 682 |