Stop jquery-ui datepicker from showing in beforeShow

后端 未结 6 2060
不知归路
不知归路 2021-01-13 13:10

I wish to do something like this:

var showme = false;

$(\'#mydatepicker\').datepicker({
    beforeShow: function(input, inst) {
        if(!showme) {
               


        
6条回答
  •  轮回少年
    2021-01-13 13:48

    Since this patch has not been merged in, I was able to come up with a hack that works pretty well. Let me know what you think:

    beforeShow: function(){
        var start = $('#dtFrom').val()
        if($.trim(start)!=''){
            start = $('#dtFrom').datepicker('getDate');
            $('#DateToDisplay').datepicker('option', 'minDate', new Date(start.getTime()));
        }
    },
        onClose: function() {
        var start = $('#dtFrom').val()
        if($.trim(start)==''){
            alert('Error! Please select a start date\/time prior to setting the date to display.');
            $('#DateToDisplay').val('')
        }
    }
    

提交回复
热议问题