The Dialog Can't Pop Up When The Date Validation Is Invalid

I am a new Yii user, I have a problem when I would like to build a website. My website has a part which is required the user input the start date and end date, I want to have one function, if the end date is set before the start date, it will show a dialog box to warn the user automatically, but I can’t do that. Have any idea to do that?

Here is my code of the two date text fields:




<td>Start

    <?php 


            $this->widget('zii.widgets.jui.CJuiDatePicker', array(

            'name'=>'COURSE_START_DATE',

            'model'=>$Cmodel,

            'attribute'=>'COURSE_START_DATE',

            'language'=>Yii::app()->language=='en_us',


            'options'=>array(

                'showAnim'=>'fold', // 'show' (the default), 'slideDown', 'fadeIn', 'fold'

                'showOn'=>'button', // 'focus', 'button', 'both'

                'buttonText'=>Yii::t('ui','Calendar'),

                'buttonImage'=>Yii::app()->request->baseUrl.'/images/calendar.png',

                'buttonImageOnly'=>true,

            ),

    )

        ?></td>


     <td>End 

    <?php 

        $this->widget('zii.widgets.jui.CJuiDatePicker', array(

            'name'=>'COURSE_END_DATE',

            'model'=>$Cmodel,

            'attribute'=>'COURSE_END_DATE',

            'language'=>Yii::app()->language=='en_us',

            'options'=>array(

                'showAnim'=>'fold', // 'show' (the default), 'slideDown', 'fadeIn', 'fold'

                'showOn'=>'button', // 'focus', 'button', 'both'

                'buttonText'=>Yii::t('ui','Calendar'),

                'buttonImage'=>Yii::app()->request->baseUrl.'/images/calendar.png',

                'buttonImageOnly'=>true,


            ),

        ));


        ?>



Try using the getDate() function on the two fields and then compare the two date objects.

If I would like to use CJuiDialog to do the thing what I want to do, how can I do that? Because I don’t know how can the CJuiDialog write inside the CJuiDatePickers’ widget. Thank you for your all kind answer and sorry for my bad English.

As far as I understand, you don’t need to write anything to the datepickers, but if you want to get the date from each, you can get it from the form elements. Something like this would probably work:




    var courseStartDate = $('input[name=COURSE_START_DATE]').datepicker('getDate');

    var courseEndDate = $('input[name=COURSE_END_DATE]').datepicker('getDate');



See the links I posted.

OK, I will try that, Thank you for your answer, Keith.