在jquery中禁用当前日期之前的日期,输入处于用户控制状态,用户控件位于更新面板中

时间:2017-03-19 14:41:48

标签: jquery asp.net updatepanel jquery-ui-datepicker bootstrap-datepicker

我尝试了很多用户无法选择以前的日期,但是后面也没有工作,但尝试了相同的代码但是 我正在使用Bootstrap Datepicker v1.4.1

以下是usercontrol.ascx代码的代码

     <asp:UpdatePanel ID="mainUpdate" runat="server">
        <ContentTemplate>
    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 form-row">
      <asp:TextBox ID="TextBox_deadline" runat="server" ToolTip="Enter your deadline in days" ClientIDMode="Static" ValidationGroup="ordernow" CssClass="form-control date-picker" placeholder="Deadline : dd/mm/yy"></asp:TextBox>              
  </div>
    </ContentTemplate>
    </asp:UpdatePanel>

关闭body标签之前的脚本代码是

<script> 
        function pageLoad() {
            var date_input = $('input[name="NewCostCalculator1$TextBox_deadline"]'); //our date input has the name "date"
            var container = $('.bootstrap-iso form').length > 0 ? $('.bootstrap-iso form').parent() : "body";
            date_input.datepicker({
                format: 'dd/mm/yyyy',
                container: container,
                todayHighlight: true,
                autoclose: true,
                orientation: "left bottom",
                minDate: 0,
            })

        } 
    </script>

点击文本框后,datepicker如下图所示,请帮助我......

enter image description here

1 个答案:

答案 0 :(得分:0)

下面的代码对我有用,如有任何建议请告诉我......

 <script>
            $(document).ready(function () {
                Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

                function EndRequestHandler(sender, args) {
                    var date_input = $('input[name="NewCostCalculator1$TextBox_deadline"]'); //our date input has the name "date"
                    var container = $('.bootstrap-iso form').length > 0 ? $('.bootstrap-iso form').parent() : "body";
                    date_input.datepicker({
                        format: 'dd/mm/yyyy',
                        container: container,
                        todayHighlight: true,
                        autoclose: true,
                        orientation: "left bottom",
                        startDate: new Date(),
                    });
                }
                var date_input = $('input[name="NewCostCalculator1$TextBox_deadline"]'); //our date input has the name "date"
                var container = $('.bootstrap-iso form').length > 0 ? $('.bootstrap-iso form').parent() : "body";
                date_input.datepicker({
                    format: 'dd/mm/yyyy',
                    container: container,
                    todayHighlight: true,
                    autoclose: true,
                    orientation: "left bottom",
                    startDate: new Date(),

                });
            });



        </script>