date-range.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
  6. <title>Pikaday - Date Range example</title>
  7. <meta name="author" content="David Bushell">
  8. <link rel="stylesheet" href="../css/pikaday.css">
  9. <link rel="stylesheet" href="../css/site.css">
  10. </head>
  11. <body>
  12. <h1>Pikaday - Date Range example</h1>
  13. <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
  14. <p><a href="https://github.com/dbushell/Pikaday"><strong>Pikaday source on GitHub</strong></a></p>
  15. <div style="display: inline-block">
  16. <label for="start">Start:</label>
  17. <br>
  18. <input type="text" id="start">
  19. </div>
  20. <div style="display: inline-block">
  21. <label for="end">End:</label>
  22. <br>
  23. <input type="text" id="end">
  24. </div>
  25. <h2>What is this?</h2>
  26. <p>Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
  27. <p class="small">Copyright &copy; 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD &amp; MIT license</p>
  28. <script src="../pikaday.js"></script>
  29. <script>
  30. var startDate,
  31. endDate,
  32. updateStartDate = function() {
  33. startPicker.setStartRange(startDate);
  34. endPicker.setStartRange(startDate);
  35. endPicker.setMinDate(startDate);
  36. },
  37. updateEndDate = function() {
  38. startPicker.setEndRange(endDate);
  39. startPicker.setMaxDate(endDate);
  40. endPicker.setEndRange(endDate);
  41. },
  42. startPicker = new Pikaday({
  43. field: document.getElementById('start'),
  44. minDate: new Date(),
  45. maxDate: new Date(2020, 12, 31),
  46. onSelect: function() {
  47. startDate = this.getDate();
  48. updateStartDate();
  49. }
  50. }),
  51. endPicker = new Pikaday({
  52. field: document.getElementById('end'),
  53. minDate: new Date(),
  54. maxDate: new Date(2020, 12, 31),
  55. onSelect: function() {
  56. endDate = this.getDate();
  57. updateEndDate();
  58. }
  59. }),
  60. _startDate = startPicker.getDate(),
  61. _endDate = endPicker.getDate();
  62. if (_startDate) {
  63. startDate = _startDate;
  64. updateStartDate();
  65. }
  66. if (_endDate) {
  67. endDate = _endDate;
  68. updateEndDate();
  69. }
  70. </script>
  71. </body>
  72. </html>