Skip to content

Instantly share code, notes, and snippets.

@abdullahbutt
Last active August 29, 2015 13:56
Show Gist options
  • Save abdullahbutt/9227637 to your computer and use it in GitHub Desktop.
Save abdullahbutt/9227637 to your computer and use it in GitHub Desktop.
jquery datepicker maxdate or maxDate and mindate or minDate
maxDateType: Date or Number or String
Default: null
The maximum selectable date. When set to null, there is no maximum.
Multiple types supported:
• Date: A date object containing the maximum date.
• Number: A number of days from today. For example 2 represents two days from today and -1 represents yesterday.
• String: A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today.
Code examples:
Initialize the datepicker with the maxDate option specified:
1 $( ".selector" ).datepicker({ maxDate: "+1m +1w" });
Get or set the maxDate option, after initialization:
1
2
3
4
5 // getter
var maxDate = $( ".selector" ).datepicker( "option", "maxDate" );
// setter
$( ".selector" ).datepicker( "option", "maxDate", "+1m +1w" );
minDateType: Date or Number or String
Default: null
The minimum selectable date. When set to null, there is no minimum.
Multiple types supported:
• Date: A date object containing the minimum date.
• Number: A number of days from today. For example 2 represents two days from today and -1 represents yesterday.
• String: A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today.
Code examples:
Initialize the datepicker with the minDate option specified:
1 $( ".selector" ).datepicker({ minDate: new Date(2007, 1 - 1, 1) });
Get or set the minDate option, after initialization:
1
2
3
4
5 // getter
var minDate = $( ".selector" ).datepicker( "option", "minDate" );
// setter
$( ".selector" ).datepicker( "option", "minDate", new Date(2007, 1 - 1, 1) );
<script>
$(document).ready(function() {
$("#todate").datepicker({
dateFormat : "yy-mm-dd",
maxDate: "0d",
minDate: "-1y"
});
$("#fromdate").datepicker({
dateFormat : "yy-mm-dd",
maxDate: "0d",
minDate: "-1y",
});
$.ajax({
type : "POST",
url : "ajax_stats/get_hourly_graphical_statistics.php",
data : "filter=today",
success : function(html) {
$("#realtimechart-container-hourly").html(html);
}
});
$.ajax({
type : "POST",
url : "ajax_stats/get_hourly_table_statistics.php",
data : "filter=today",
success : function(html) {
$("#box_content_stats_hourly").html(html);
}
});
$.blockUI({
css : {
border : 'none',
padding : '50px',
opacity : .5,
color : '#fff',
background : 'url(http://admin.activemobile.com/mx/img/spinner.gif) no-repeat 10px 10px'
}
});
setTimeout($.unblockUI, 1000);
});
function fetchFilteredRecords(val) {
if (val == "custom") {
$("#custom_filtering").show();
} else {
$("#custom_filtering").hide();
$.ajax({
type : "POST",
url : "ajax_stats/get_hourly_graphical_statistics.php",
data : "filter=" + val,
success : function(html) {
$("#realtimechart-container-hourly").html(html);
}
});
$.ajax({
type : "POST",
url : "ajax_stats/get_hourly_table_statistics.php",
data : "filter=" + val,
success : function(html) {
$("#box_content_stats_hourly").html(html);
$("#csv").attr("href", "publisher_csv.php?report=hour&filter=" + val);
$("#pdf").attr("href", "pdf/hourly_pub_pdf.php?filter=" + val);
$("#excle").attr("href", "excle/pub_excle.php?report=hour&filter=" + val);
}
});
$.blockUI({
css : {
border : 'none',
padding : '50px',
opacity : .5,
color : '#fff',
background : 'url(http://admin.activemobile.com/mx/img/spinner.gif) no-repeat 10px 10px'
}
});
setTimeout($.unblockUI, 1000);
}
}
function customFilters() {
var todate = $("#todate").val();
var fromdate = $("#fromdate").val();
var val = $("#report_filters").val();
if (todate != "" && fromdate != "") {
$.ajax({
type : "POST",
url : "ajax_stats/get_hourly_graphical_statistics.php",
data : "filter=" + val + "&todate=" + todate + "&fromdate=" + fromdate,
success : function(html) {
$("#realtimechart-container-hourly").html(html);
}
});
$.ajax({
type : "POST",
url : "ajax_stats/get_hourly_table_statistics.php",
data : "filter=" + val + "&todate=" + todate + "&fromdate=" + fromdate,
success : function(html) {
$("#box_content_stats_hourly").html(html);
$("#csv").attr("href", "publisher_csv.php?report=hour&filter=" + val + "&todate=" + todate + "&fromdate=" + fromdate);
$("#pdf").attr("href", "pdf/hourly_pub_pdf.php?filter=" + val + "&todate=" + todate + "&fromdate=" + fromdate);
$("#excle").attr("href", "excle/pub_excle.php?report=hour&filter=" + val + "&todate=" + todate + "&fromdate=" + fromdate);
}
});
} else {
alert("Please enter required date range filters.")
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment