当我有两个日期选择器表单时,如何将用户限制在1个月的日期范围内


how to limit the user to 1 month date range only when i have two date picker forms?

我有两个输入表单,"Date From"和"Date To",它们都使用jquery的日期选择器。我的问题是,如何限制用户使用这两个日期选择器只选择一个月的范围?

这是"日期起始"日期选择器的片段

                $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;'
                                )
                        )
                );

目标是这样的,假设用户选择的日期是从1月1日到2月1日,就是这样,如果用户试图选择的日期范围超过1个月,就应该阻止。。。怎么做?

这里的解决方案将为您提供如何找到月份差异的想法,

月差异