如何在jquery UI datepicker中禁用前几天

时间:2017-06-08 12:30:09

标签: javascript jquery

我想在明天前禁用,并将明天设置为默认值,但我今天的代码显示为今天的默认和禁用天数。

视图:

   <input id="date_modified" type="text" class="form-control" value="">

jquery的:

 $('#date_modified').persianDatepicker({
            observer: true,
            format: 'YYYY/MM/DD',
            maxDate: new Date(),


        })

                .pDatepicker('setDate');

    });

1 个答案:

答案 0 :(得分:2)

 <!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
  var tomorrow = new Date();
    tomorrow.setDate(tomorrow.getDate() + 1);
    //Following line of code is to set the default and minDate of datepicker.
    $( "#datepicker" ).datepicker({minDate: tomorrow,defaultDate:tomorrow});
    //Following line of code is to set value of default date on text box.
    $("#datepicker").val($.datepicker.formatDate('mm/dd/yy', tomorrow));
  } );
  </script>
</head>
<body>
 
<p>Date: <input type="text" id="datepicker"></p>
 
 
</body>
</html>