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
You can use this code to toggle disabled with jQuery Datepicker and with any other form element also.
/***
*This is the toggle disabled function Start
*
**/
(function($) {
$.fn.toggleDisabled = function() {
return this.each(function() {
this.disabled = !this.disabled;
if ($(this).datepicker("option", "disabled")) {
$(this).datepicker("option", "disabled", false);
} else {
$(this).datepicker("option", "disabled", true);
}
});
};
})(jQuery);
/***
*This is the toggle disabled function Start
*Below is the implementation of the same
**/
$(".filtertype").click(function() {
$(".filtertypeinput").toggleDisabled();
});
/***
*Implementation end
*
**/
$("#from").datepicker({
showOn: "button",
buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
buttonImageOnly: true,
buttonText: "Select date",
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
numberOfMonths: 1,
onClose: function(selectedDate) {
$("#to").datepicker("option", "minDate", selectedDate);
}
});
$("#to").datepicker({
showOn: "button",
buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif ",
buttonImageOnly: true,
buttonText: "Select date",
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
numberOfMonths: 1,
onClose: function(selectedDate) {
$("#from").datepicker("option", "maxDate", selectedDate);
}
});