Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/474.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 蛋糕日期验证_Javascript_Jquery_Cakephp_Datepicker - Fatal编程技术网

Javascript 蛋糕日期验证

Javascript 蛋糕日期验证,javascript,jquery,cakephp,datepicker,Javascript,Jquery,Cakephp,Datepicker,我有以下代码,允许用户添加订单详细信息。我使用数据采集器jQuery来显示日期的日历。例如,在订单日期字段中,我希望阻止用户选择未来日期。我该怎么做? 我的代码如下: edit.ctp: <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Datepicker - Default functionality</title>

我有以下代码,允许用户添加订单详细信息。我使用数据采集器jQuery来显示日期的日历。例如,在订单日期字段中,我希望阻止用户选择未来日期。我该怎么做? 我的代码如下: edit.ctp:

<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>jQuery UI Datepicker - Default functionality</title>
        <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
        <link rel="stylesheet" href="/resources/demos/style.css">
        <script>
            $(function() {
                $("#datepicker").datepicker({
                    changeMonth: true,
                    changeYear: true,
                    yearRange: '1950:2020',
                    dateFormat: "yy-mm-dd"
                });

                $("#datepicker2").datepicker({
                    changeMonth: true,
                    changeYear: true,
                    yearRange: '1950:2020',
                    dateFormat: "yy-mm-dd"
                });

            });
        </script>
    </head>
    <?php
    $usertype = $this->SESSION->read('User.usertype');
    ?>
    <body>
        <div class="orders form">
            <?php echo $this->Form->create('Order'); ?>
            <fieldset>
                <legend><?php echo __('Edit Order Details'); ?></legend>
                <?php
                echo $this->Form->input('id');
                echo $this->Form->input('invoice_number', array('required' => false));
                echo $this->Form->input('order_date', array('required' => false, 'id' => 'datepicker', 'type' => 'text'));
                echo $this->Form->input('payment_type', array('required' => false, 'options' => array('Cash' => 'Cash', 'EFTPOS' => 'EFTPOS', 'CC' => 'CC', 'Cheque' => 'Cheque', 'PayPal' => 'PayPal'), 'empty' => '(choose one)'));
                echo $this->Form->input('order_type', array('required' => false, 'options' => array('Email' => 'Email', 'Telephone' => 'Telephone', 'Web' => 'Web'), 'empty' => '(choose one)'));
                echo $this->Form->input('date_promised', array('required' => false, 'id' => 'datepicker2', 'type' => 'text'));
                echo $this->Form->input('order_description', array('required' => false));
                echo $this->Form->input('order_comments', array('required' => false));
                echo $this->Form->input('order_total', array('required' => false));
                echo $this->Form->input('amount_deposited', array('required' => false));
                echo $this->Form->input('balance_due', array('required' => false));

                /* echo $this->Form->input('customers_id', array('required'=>false));
                  echo $this->Form->input('employees_id', array('required'=>false));
                 */
                echo $this->Form->input('customers_id', array('label' => 'Customer Name', 'options' => $customers, 'label' => 'Customer Name', 'required' => false));
                echo $this->Form->input('employees_id', array('label' => 'Employee name', 'options' => $employees, 'label' => 'Employee name', 'required' => false));
                ?>
            </fieldset>
            <?php echo $this->Form->end(__('Submit')); ?>
        </div
    </body>
</html>

jQuery UI日期选择器-默认功能
$(函数(){
$(“#日期选择器”)。日期选择器({
变化月:对,
变化年:是的,
年份范围:“1950:2020”,
日期格式:“年月日”
});
$(“#日期选择器2”)。日期选择器({
变化月:对,
变化年:是的,
年份范围:“1950:2020”,
日期格式:“年月日”
});
});
试试这个

$(function() { $("#datepicker").datepicker({  
      maxDate: '0'}); 
});
这将从当前日期(即今天)起将maxDate设置为+0天。 参考是小提琴:

jquery:

 $("#datepicker").datepicker({
     changeMonth: true,
     changeYear: true,
     yearRange: '1950:2020',
     dateFormat: "yy-mm-dd",
     maxDate: 0
});