Check that the date entered is not already passed

150 Views Asked by At

I have a date field in a form widget CActiveForm. The date field is a CJuiDatePicket widget. I would like to put a control so that the user can not enter a date that is in the past.

My code is

<div class="row">
    <?php echo $form->labelEx($model,'date'); ?>
    <?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(
                            'name'=>'Menu[date]',
                            'id'=>'Menu_date',
                        'value'=>Yii::app()->dateFormatter->format("yyyy-MM-dd",strtotime($model->date)),
                            'options'=>array(
                            'showAnim'=>'fold',
                            'dateFormat'=>'yy-mm-dd',
                            'minDate'=>'new Date()'
                            ),
                            'htmlOptions'=>array(
                            'style'=>'height:20px;'
                            ),
                    ));  ?>
    <?php echo $form->error($model,'date'); ?>
</div>

The user no longer has the possibility to select the dates in the pass. Now I want a controller that has an error message if input is a date manually in the pass.

2

There are 2 best solutions below

0
On

using minDate = '0' user can not enter previous,

Thanks

3
On

Set like

 minDate: 0,//0th days from presnt day will be selectable