2

像这样禁用它后如何使日期选择器图像可单击/启用

 $("#_ctl0_MainContent_txtFromDateTime").datepicker({
    showOn: "button",
    buttonImage: "../images/calendar.gif",
    buttonImageOnly: true,
    buttonText: "Please Select Date",
    onSelect: function() {
        //            $(this).datepicker("option", "dateFormat", "MM d yy")
        $("#_ctl0_MainContent_hdnFromDateTime").val($(this).val());
    }
});
$("#_ctl0_MainContent_txtFromDateTime").datepicker('disable');

如果我使用

  $("#_ctl0_MainContent_txtFromDateTime").datepicker('enable');

它不起作用

4

2 回答 2

0

使用 settime out 作为日期

$.validator.addMethod("endDate", function(value, element) { 

    var startDate = $('#txt_reg_form').val(), 
    ret = Date.parse(startDate) <= Date.parse(value) || value == ""; 

    if(!ret){ /*IF NOT VALID DATE*/

        /*TRY DISABLING DATEPICKER FOR A MOMENT*/
        $("#txt_reg_form").datepicker('disable');

        /*SET TIMEOUT TO ENABLE IT AFTER 1 SECOND*/
        setTimeout(function(){
               $("#txt_reg_form").datepicker('enable');
           }, 1000);
    }
    return ret;
 }
, "To date should be greater then From date"
);
于 2012-06-08T06:21:54.290 回答
0

最后我在禁用数据选择器后启用了它。首先我加载了整个数据选择器,然后启用它

 $("#_ctl0_MainContent_txtFromDateTime").datepicker({
showOn: "button",
buttonImage: "../images/calendar.gif",
buttonImageOnly: true,
buttonText: "Please Select Date",
onSelect: function() {
    //            $(this).datepicker("option", "dateFormat", "MM d yy")
    $("#_ctl0_MainContent_hdnFromDateTime").val($(this).val());
}

});

 $("#_ctl0_MainContent_txtFromDateTime").datepicker('disable');

让它像这样禁用。在那之后

  var disabled = $("#_ctl0_MainContent_txtFromDateTime").datepicker("option", "disabled");
    //setter
    $("#_ctl0_MainContent_txtFromDateTime").datepicker("option", "disabled", false);
    $("#_ctl0_MainContent_txtFromDateTime").datepicker({ constrainInput: true });
    $("#_ctl0_MainContent_txtFromDateTime").datepicker("enable");
于 2012-06-08T14:49:03.923 回答