Skip to content

Instantly share code, notes, and snippets.

@webspace-jp
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webspace-jp/4f027cca68a4e7c1b746 to your computer and use it in GitHub Desktop.
Save webspace-jp/4f027cca68a4e7c1b746 to your computer and use it in GitHub Desktop.
$(function(){
$.datepicker.setDefaults( $.datepicker.regional[ "ja" ] );
$(".datepicker").datepicker({
beforeShow: function (input, inst) {
var $this = $(input);
var begin = $this.data('begin') || '';
if (begin) {
$this.datepicker("option", "minDate", $(begin).val());
}
var end = $this.data('end') || '';
if (end) {
$this.datepicker("option", "maxDate", $(end).val());
}
},
onSelect: function (dateText, inst) {
var $this = $(inst.input);
var begin = $this.data('begin') || '';
if (begin) {
$(begin).datepicker("option", "maxDate", dateText);
}
var end = $this.data('end') || '';
if (end) {
$(end).datepicker("option", "minDate", dateText);
}
},
});
$('[data-toggle=datepicker]').each(function () {
var target = $(this).data('target') || '';
if (target) {
$(this).bind("click", function () {
$(target).datepicker("show");
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment