I have two textbox from and to which shows month and year picker. I want to set mindate(month) for to textbox from the value from textbox which user has selected.
Here is my jscript but its not working.
$(function () {
$("#<%=frm_txtdatefrm.ClientID %>").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'M yy',
showButtonPanel: true,
onClose: function () {
var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
$(this).datepicker('refresh');
},
beforeShow: function () {
if ((selDate = $(this).val()).length > 0) {
iYear = selDate.substring(selDate.length - 4, selDate.length);
iMonth = jQuery.inArray(selDate.substring(0, selDate.length - 5), $(this).datepicker('option', 'monthNames'));
$(this).datepicker('option', 'defaultDate', new Date(iYear, iMonth, 1));
$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
}
if ((selDate = $(this).val()).length > 0) {
year = selectedDate.substring(selectedDate.length - 4, selectedDate.length);
month = jQuery.inArray(selectedDate.substring(0, selectedDate.length - 5), $(this).datepicker('option', 'monthNamesShort'));
$("#<%=frm_txtdateto.ClientID %>").datepicker("option", "mindate", new Date(year, month, 1));
}
}
});
$("#<%=frm_txtdatefrm.ClientID %>").focus(function () {
$(".ui-datepicker-calendar").hide();
$("#ui-datepicker-div").position({
my: "center top",
at: "center bottom",
of: $(this)
});
});
$("#<%=frm_txtdatefrm.ClientID %>").blur(function () {
$(".ui-datepicker-calendar").hide();
});