var minimumdate = document.getElementById("PageContent_hdnVdate").value;
var currentDate = new Date("30/Apr/2025");
function GetRestart1() {
$("#<%=txt_installationDate.ClientID %>").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd/M/yy",
maxDate: currentDate,
minDate: minimumdate,
showOn: "button",
showOn: "both",
buttonImage: "../img/calendar.png",
buttonImageOnly: true,
onClose: function (selectedDate) {
$("#<%=txt_installationDate.ClientID %>").datepicker("option", "minDate", selectedDate);
}
});
}
Loading
Tuhin PaulPosted Jan 26, 2025, 1:58 PM
Below I am sharing a demo code: JSFiddle - Code Playground
and also the full code:
Tuhin PaulPosted Jan 26, 2025, 1:49 PM
Part -1
To enable future dates up to 30-Apr-2025 in your date picker, you need to check that the
maxDateoption is set correctly. In your code, you are already settingmaxDatetocurrentDate, which is defined asnew Date("30/Apr/2025").Date Format for
currentDate:Changed
new Date("30/Apr/2025")tonew Date("2025-04-30").The ISO format (
YYYY-MM-DD) is more reliable across different browsers and environments.showOnOption:You had
showOn: "button"andshowOn: "both"duplicated. I keptshowOn: "both"to check the date picker shows on both the input field and the button click.onCloseFunction:This function updates the
minDatefor other date pickers if needed. If you don’t have other date pickers to synchronize, you can remove this part.Amira BedhiafiPosted Jan 25, 2025, 6:48 PM
I think your issue is how the
currentDateis being set. Thenew Date("30/Apr/2025")syntax may not work as expected due to potential inconsistencies in parsing date formats across browsers.