JQuery datePicker date reset

前端 未结 6 1255
耶瑟儿~
耶瑟儿~ 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:04

    1. Change the Done label to Clear and add code to clear

      $(document).ready(function () {
          $("#startdate").datepicker({
              showOn: 'both',
              buttonImageOnly: true,
              buttonImage: "css/images/calendar.gif",
              showButtonPanel: true,
              closeText: 'Clear',
              onClose: function (dateText, inst) {
                  $(this).val('');
              }
          });
      });
      
    2. Add Cancel button to the calendar

      $("#termdate").datepicker({
          showOn: 'both',
          buttonImageOnly: true,
          buttonImage: "css/images/calendar.gif",
          showButtonPanel: true,
          beforeShow: function (input) {
              setTimeout(function () {
                  var buttonPane = $(input).datepicker("widget")
                      .find(".ui-datepicker-buttonpane");
                  var btn = $('');
                  btn.unbind("click").bind("click", function () {
                      $.datepicker._clearDate(input);
                  });
                  btn.appendTo(buttonPane);
              }, 1);
          }
      });
      

提交回复
热议问题