javascript - End Date should be greater than Start Date in Yii Bootstrap datepickerRow -
i using yii bootstraps datepickerrow : check this
i want end_date depending on start_date. i.e. end_date should greater start date. i've spent couple of hours on google check whether in-built solution available didn't found solution. after written own js code which's think fine not working.
i've achieved thing cjuidatepicker , booming.
check working code yii cjuidatepicker
but don't know why not working yii bootstrap datepickerrow.
any appreciated.
following code:
<?php echo $form->datepickerrow( $identitycard, 'date_of_issue', array( 'onchange' => 'setenddate("passport_date_of_expiry", this)', 'class' => "input-small", 'labeloptions' => array('label' => 'date of issue <span class="required">*</span>'), 'value' => $passportarr['date_of_issue'], 'name' => 'passport[date_of_issue]', 'readonly' => true, 'options' => array( 'autoclose' => true, 'showanim' => 'fold', 'format' => 'yyyy-mm-dd', 'enddate' => '-infinity' ), 'prepend' => '<i class="icon icon-calendar"></i>', 'hint' => 'yyyy-mm-dd' ) ); echo $form->datepickerrow( $identitycard, 'date_of_expiry', array( 'class' => "input-small", 'labeloptions' => array('label' => 'date of expiry <span class="required">*</span>'), 'value' => $passportarr['date_of_expiry'], 'name' => 'passport[date_of_expiry]', 'readonly' => true, 'options' => array( 'autoclose' => true, 'showanim' => 'fold', 'format' => 'yyyy-mm-dd', ), 'prepend' => '<i class="icon icon-calendar"></i>', 'hint' => 'yyyy-mm-dd' ) ); ?>
// js code
function setenddate(id, date) { var selecteddate = $(date).val(); $("#" + id).datepicker({ startdate: selecteddate, format: "yyyy-mm-dd" }); }
in js function setenddate
, second parameter date
not jquery element (this
in parameter in datepickerrow). can't read jquery selector.
in function setenddate
can read input value date.value;
instead $(date).val();
edit:
setenddate
function should work changes (refer plugin docs related in source code of yiibooster, example in yii-booster installation : protected/components/bootstrap/assets/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js ):
function setenddate(id, date) { $("#" + id).val(date.value); $("#" + id).datepicker('setstartdate' , date.value); }
Comments
Post a Comment