Php cjuidatepicker根据第一个日期字段yii中选定的日期限制第二个日期字段中的日期 结束日期
我想限制“结束日期”字段中的日期,该字段不应低于“开始日期”中的日期,例如,如果“开始日期”中选择的日期是2014年6月1日,则允许用户选择2014年6月1日之后的日期,不少于2014年6月1日Php cjuidatepicker根据第一个日期字段yii中选定的日期限制第二个日期字段中的日期 结束日期,php,yii,Php,Yii,我想限制“结束日期”字段中的日期,该字段不应低于“开始日期”中的日期,例如,如果“开始日期”中选择的日期是2014年6月1日,则允许用户选择2014年6月1日之后的日期,不少于2014年6月1日 如何在结束日期字段中限制日期拾取?使用jquery的简单方法 <?php $this->widget('zii.widgets.jui.CJuiDatePicker',array( 'name'=>'Settings[start_date]',
如何在结束日期字段中限制日期拾取?使用jquery的简单方法
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'name'=>'Settings[start_date]',
'value'=>date("d-m-Y",strtotime($model->start_date)),
'options'=>array(
//'buttonImage'=>Yii::app()->theme->getBaseUrl().'/img/calendar.png',
//'buttomImageOnly'=>true,
//'showOn'=>'button',
'changeMonth'=> true,
'changeYear'=> true,
'showAnim'=>'fold',
'dateFormat' => 'dd-mm-yy',
),
'htmlOptions'=>array(
'id'=>'start_date',
),
));
?>
<?php echo $form->error($model,'start_date'); ?>
</div></div></td>
<td style="width:516px"><div class="formItem leftLabel"><label for="end_date" class="required">End Date </label><div class="formInputBox" style="width:210px;">
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'name'=>'Settings[end_date]',
'value'=>date("d-m-Y",strtotime($model->end_date)),
'options'=>array(
//'buttonImage'=>Yii::app()->theme->getBaseUrl().'/img/calendar.png',
//'buttomImageOnly'=>true,
//'showOn'=>'button',
'changeMonth'=> true,
'changeYear'=> true,
'showAnim'=>'fold',
'dateFormat' => 'dd-mm-yy',
),
'htmlOptions'=>array(
'id'=>'end_date',
),
));
?>
<?php echo $form->error($model,'end_date'); ?>
<script>
$('#start_date').change(function(){
var start_date = $(this).val();
$("#end_date").datepicker( "option","minDate",start_date);
});
$('#end_date').change(function(){
var end_date = $(this).val();
$("#start_date").datepicker( "option","maxDate",end_date);
});
</script>
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'model' => $model,
'attribute'=>'start_date',
'options'=>array(
'changeMonth'=> true,
'changeYear'=> true,
'showAnim'=>'fold',
'dateFormat' => 'dd-mm-yy',
'onSelect' => 'js:function( selectedDate ) {
$( "#' . CHtml::activeId($model, 'end_date') . '" ).datepicker("option", "minDate", selectedDate);
}'
),
'htmlOptions'=>array(
'id'=>'start_date',
),
));
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'model' => $model,
'attribute'=>'end_date',
'options'=>array(
'changeMonth'=> true,
'changeYear'=> true,
'showAnim'=>'fold',
'dateFormat' => 'dd-mm-yy',
),
'htmlOptions'=>array(
'id'=>'end_date',
),
));