JQuery DatePicker ReadOnly

后端 未结 14 2286
温柔的废话
温柔的废话 2020-12-03 04:35

When I make my datepicker read-only, I see that the user cannot type anything into the text box.

$(\"#datepicker\").attr(\'readonly\', \'readonly\');
         


        
14条回答
  •  遥遥无期
    2020-12-03 05:10

          beforeShow: function(el) {
                if ( el.getAttribute("readonly") !== null ) {
                    if ( (el.value == null) || (el.value == '') ) {
                        $(el).datepicker( "option", "minDate", +1 );
                        $(el).datepicker( "option", "maxDate", -1 );
                    } else {
                        $(el).datepicker( "option", "minDate", el.value );
                        $(el).datepicker( "option", "maxDate", el.value );
                    }
                }
            },
    

提交回复
热议问题