JQuery datePicker date reset

前端 未结 6 1247
耶瑟儿~
耶瑟儿~ 2020-12-14 20:37

I would like to add a \"Reset\" control to the datepicker at the bottom of the calendar - where the \"close\" control goes. This would enable the user to reset the input tie

6条回答
  •  悲&欢浪女
    2020-12-14 21:16

    I was going through this same problem, that is, no option available to empty the datepicker. I then found this super useful comment with a sweet piece of code posted here:

    One quick way you can add the clear feature even on read only fields is to add the following code to your existing datepicker control:

    }).keyup(function(e) {
        if(e.keyCode == 8 || e.keyCode == 46) {
            $.datepicker._clearDate(this);
        }
    });
    

    This will enable people to highlight (which they can even on Read Only fields) and then use the backspace or delete to remove the date using the internal _clearDate function.

提交回复
热议问题