i have 2 input forms, the "Date From" and "Date To" , both are using jquery's date picker My question is, how to limit the user to select only a range of one month using those two datepickers ?

this is the snippet of the "Date From" date picker

                $this->widget('zii.widgets.jui.CJuiDatePicker',
                        array(
                                'model' => $model,
                                'attribute' => 'STARTDATE',
                                'options' => array(
                                        'dateFormat'=>'yy-mm-dd',
                                        'showOn'=> 'both',
                                        'buttonImage'=> Yii::app()->theme->baseUrl."/images/calendar.gif",
                                        'buttonImageOnly' => 'true',
                                        'dateFormat'=>'dd-mm-yy',
                                        'changeMonth' => 'true',
                                        'changeYear' => 'true',
                                        'showButtonPanel' => 'true',
                                        'constrainInput' => 'false',
                                        'duration'=>'fast',
                                        'showAnim' =>'slide',
                                        'ampm' => 'true',
                                        'onSelect' => 'js:function(selectedDate) {$( "#paymenttrans_TRANSDATETO" ).datepicker( "option", "minDate", selectedDate );}'
                                ),
                                'flat'=>false,
                                'htmlOptions'=>array(
                                'readonly'=>'TRUE',
                                'size'=>'10',
                                'style'=>'margin-right: 5px;'
                                )
                        )
                );

the objective is like this, let's say the user selects date from January 1 to February 1, that's it, if the user tries to select that has a range of more than 1 month , it should be prevented...how to do that?

有帮助吗?

解决方案

Here Solution would give you an Idea of how to find Diff in Months,

Difference in Months

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top