Yii Framework Forum: The Dialog Can't Pop Up When The Date Validation Is Invalid - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

The Dialog Can't Pop Up When The Date Validation Is Invalid Rate Topic: ***** 1 Votes

#1 User is offline   NathanL 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 27-March 13
  • Location:Hong Kong

Posted 27 March 2013 - 01:56 AM

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,

            ),
        ));

        ?>

0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,707
  • Joined: 04-March 10
  • Location:UK

Posted 27 March 2013 - 04:33 AM

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

#3 User is offline   NathanL 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 27-March 13
  • Location:Hong Kong

Posted 27 March 2013 - 08:21 PM

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.
0

#4 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,707
  • Joined: 04-March 10
  • Location:UK

Posted 28 March 2013 - 03:51 AM

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.
0

#5 User is offline   NathanL 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 27-March 13
  • Location:Hong Kong

Posted 28 March 2013 - 04:42 AM

View PostKeith, on 28 March 2013 - 03:51 AM, said:

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users