I need to both enable and set the date format of Jquery UI Datepicker as shown in the example below. I have tried different permutations but they do not work. I have also looked online but it appears that I can use only one or the other. Please let me know if this is possible
$("#frm-renew-btn").on("click", function() {
$('#renewDate').datepicker({
disabled: true
});
$('#renew-dlg').dialog({
closeOnEscape: false,
modal: true,
draggable: false,
resizable: false,
hide: {
effect: 'fade',
duration: 100
},
stack: true,
zIndex: 10000,
fluid: true,
dialogClass: 'ui-dialog-osx',
open: function(event, ui) {
$('#renewDate').datepicker({
dateFormat: "dd MM yy",
title: 'Test Dialog',
minDate: 0,
maxDate: 365
}).val();
$('#renewDate').datepicker('enable')
},
close: function(event, ui) {
$('#renewDate').datepicker('disable');
},
buttons: [{
id: "btn-ok-dlg",
text: "OK",
click: function() {
confirm_renewal();
$(this).dialog('destroy');
}
}, {
id: "btn-close-dlg",
text: "Cancel",
click: function() {
$(this).dialog('destroy');
$('#renew-dlg').empty();
}
}],
});
});
<div id="renew-dlg" title="Renew your Application">Enter new End Date: <input type="text" id="renewDate" /></div>
,as a statement separator in JS is a really bad idea. I'd strongly suggest always using;instead.