Last active
May 24, 2021 21:18
-
-
Save jamesperrin/8de333d728646127ff87fca1be7fec2b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* jQuery plugin that converts value to date | |
* @requires https://jqueryui.com/ | |
* @param {Node} True or False to Disable element | |
* @return {String} Formatted date | |
*/ | |
(function ($) { | |
$.fn.getDateMmddyy = function () { | |
if (this.val() == null) { | |
return null; | |
} | |
return $.datepicker.parseDate("yyyy/mm/dd", this.val()); | |
} | |
}(jQuery)); | |
/* | |
* jQuery plugin that converts value to date | |
* @requires https://jqueryui.com/ | |
* @param {Node} The element | |
* @return {String} Formatted date and time | |
*/ | |
(function ($) { | |
$.fn.getDateTimeMmddyy = function () { | |
if (this.val() == null) { | |
return null; | |
} | |
return $.datepicker.parseDate("yyyy/mm/dd", this.val()); | |
} | |
}(jQuery)); | |
$(function () { | |
// jQuery UI DatePicker | |
$("body").delegate(".jqui--datetime", "focus", function () { | |
if (!$(this).hasClass("hasDatepicker")) { | |
const minDate = getDateMmddyy($(this).data("val-rangedate-min")); | |
const maxDate = getDateMmddyy($(this).data("val-rangedate-max")); | |
$(this).datepicker({ | |
showButtonPanel: true, | |
dateFormat: "mm/dd/yy", | |
minDate: minDate, | |
maxDate: maxDate, | |
numberOfMonths: 1 | |
}); | |
} | |
$.datepicker._gotoToday = function (id) { | |
$(id).datepicker('setDate', new Date(maxDate)).datepicker('hide').blur(); | |
}; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment