【发布时间】:2014-05-04 09:29:27
【问题描述】:
我有以下代码,允许用户添加订单详细信息。我正在使用 datapicker jQuery 来显示日期日历。例如订单日期字段,我想阻止用户选择未来的日期。我怎样才能做到这一点? 我的代码如下: 编辑.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>
有人可以帮忙吗?
【问题讨论】:
标签: javascript jquery cakephp datepicker