Manual date entry validation for jQuery UI Datepicker maxDate option

前端 未结 4 1701
无人共我
无人共我 2020-12-16 01:31

I have jQuery datepicker on a page that needs to allow manual entry of the date, but also needs to validate that the date is no more than one day ahead. The picker control

4条回答
  •  隐瞒了意图╮
    2020-12-16 02:13

    I had exactly the same requirement and here is the solution that worked for me like a charm:

      $(".datepicker").attr("placeholder", "mm-dd-yyyy").change(function(){
        $(this).datepicker('setDate', $(this).datepicker('getDate'));
      }).datepicker({
          showOn: "button",
          maxDate: "+1",
          showOtherMonths: true
      });
    

    Modified fiddle here referenced from Salman A's answer

提交回复
热议问题