Yii Framework Forum: Yii – Add A Jquery Datepicker From And To Date - Yii Framework Forum

Jump to content

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

Yii – Add A Jquery Datepicker From And To Date Yii – Add A Jquery Datepicker From and Todate disable before from date Rate Topic: -----

#1 User is offline   kiran.irali 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 27-May 13
  • Location:Belgaum

Posted 06 June 2013 - 03:38 AM

Yii – Add A Jquery Datepicker From and To date disable before dates from_date in To_date field
Here is the code
<div class="row">
        <?php echo $form->labelEx($model,'from_date'); ?>
        <?php echo $form->textField($model,'from_date'); ?>
        <?php echo $form->error($model,'from_date'); ?>
</div>
<div class="row">
        <?php echo $form->labelEx($model,'to_date'); ?>
        <?php echo $form->textField($model,'to_date'); ?>
        <?php echo $form->error($model,'to_date'); ?>
</div>
        <script>
        jQuery(function() {
                var dates = jQuery( "#<?php echo CHtml::activeID($model, 'from_date')?>, #<?php echo CHtml::activeID($model, 'to_date')?>" ).datepicker({
                        defaultDate: "+1w",
                        dateFormat: "yy-mm-dd",
                        changeMonth: true,
                        numberOfMonths: 1,
                        onSelect: function( selectedDate ) {
                                var option = this.id == "<?php echo CHtml::activeID($model, 'from_date')?>" ? "minDate" : "maxDate",
                                        instance = jQuery( this ).data( "datepicker" ),
                                        date = jQuery.datepicker.parseDate(
                                                instance.settings.dateFormat ||
                                                jQuery.datepicker._defaults.dateFormat,
                                                selectedDate, instance.settings );
                                dates.not( this ).datepicker( "option", option, date );
                        }
                });
        });
        </script>

0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,071
  • Joined: 16-February 11
  • Location:Japan

Posted 06 June 2013 - 05:01 AM

/* Moved from "General Discussion for Yii 1.1.x" to "Tips, Snippets and Tutorials" ...
and also applied the proper mark ups */

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