Here is my code:
$("#myCheckBox").click(function () {
if (!$(this).is(':checked')) {
$('#txtDateFrom').attr('readonly', true);
$('#txtDateTo').attr('readonly', true);
$('#txtDateFrom').val('01/01/2012');
$('#txtDateTo').val('31/12/2012');
$('#txtDateFrom').datepicker(this.checked ? "disable" : "disable");
$('#txtDateTo').datepicker(this.checked ? "disable" : "disable");
}
else {
$('#txtDateFrom').attr('readonly', false);
$('#txtDateTo').attr('readonly', false);
$('#txtDateFrom').datepicker(this.checked ? "disable" : "enable");
$('#txtDateTo').datepicker(this.checked ? "disable" : "enable");
$('#txtDateFrom').datepicker({ dateFormat: 'dd/mm/yy' });
$('#txtDateTo').datepicker({ dateFormat: 'dd/mm/yy' });
}
});
After uncheking the checkBox, and checking it again, the textboxes are still disabled. Why?