In my php-file, I want to use the jQuery Datepicker.
When my file loads, I create the Datepicker disabled.
Then, when a special field in my php-file (it is a form) is filled, I want to enable the Datepicker.
So, initially my Datepicker looks like this:
$("#from").datepicker({
showOn: "both",
buttonImage: "calendar.gif",
buttonImageOnly: true,
buttonText: "Kalender",
showAnim: "drop",
dateFormat: "dd.mm.yy",
changeMonth: true,
changeYear: true,
showButtonPanel: true,
showWeek: true,
firstDay: 1,
dayNamesMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
weekHeader: "KW",
disabled: true,
onClose: function(selectedDate) {
$("#to").datepicker("option", "minDate", selectedDate);
}
});
This works just fine, no problem so far. The problem comes, when I want to disable the field.
If a special field is filled, I call $("#from").datepicker('enable');
This also works fine, BUT now I want to disable it again if the special field I mentioned it empty again.
Then I use $("#from").datepicker('disable');
and the field itself is grayed, but I can still use the field to enter values, the calender pops up and even the calender-image next to the box is clickable.
Anyone has an idea why this is the case? Am I missing something?
$("#from").datepicker('disable');
should work, but you can also try this:
$( "#from" ).datepicker( "option", "disabled", true );