How to clear a DatePicker

前端 未结 2 459
攒了一身酷
攒了一身酷 2021-01-19 02:34

I have a DatePicker for selecting birthday.

This is going to be used for some filtering, and after the filtering, I will like the value to be

相关标签:
2条回答
  • 2021-01-19 02:46

    If you want to clear the TextField of the DatePicker, you can use :

    datepicker.getEditor().clear();
    

    If you want to clear the value and the textfield, use :

    datePicker.setValue(null);
    
    0 讨论(0)
  • 2021-01-19 02:53

    just add this code

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

    You can use backspace to clear field even if it has in read only mode. Source

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