Disable/enable datepicker on checkBox click

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?

Answers


This might be your problem:

$('#txtDateFrom').datepicker(this.checked ? "disable" : "disable");
$('#txtDateTo').datepicker(this.checked ? "disable" : "disable");

Should be something like:

$('#txtDateFrom').datepicker(this.checked ? "disable" : "enable");
$('#txtDateTo').datepicker(this.checked ? "disable" : "enable");

Need Your Help

CSV encoding specification

java encoding csv

I am creating a CSV and writing content in UTF-8 to support German and English by specifying encoding as below