JQuery DatePicker ReadOnly

后端 未结 14 2284
温柔的废话
温柔的废话 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:14

    I came up with another solution that is different than what had been proposed. When the date picker is used, it creates a div similar to a pop-up that is positioned when the input field is clicked on. To remove it, I just set the visibility property of the CSS so that it doesn't show up.

    if ($('.yourDatepickerSelector').prop('readonly')) {
        $('#ui-datepicker-div').css({ 'visibility': 'hidden' })
    } else { $('#ui-datepicker-div').css({ 'visibility': 'visible' }) }
    

    This also seems to post correctly to the server, and should not effect any of the settings associated with it.

    0 讨论(0)
  • 2020-12-03 05:14
    <sj:datepicker id="datepickerid" name="datepickername" displayFormat="%{formatDateJsp}" readonly="true"/>
    

    Works for me.

    0 讨论(0)
提交回复
热议问题