【问题标题】:how to accept corect date format in yii 1如何在 yii 1 中接受正确的日期格式
【发布时间】:2017-03-23 10:47:42
【问题描述】:

我的视图文件中有以下代码:

 <?= $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                'model' => $model,
                'attribute' => 'time',
                'language' => 'ru',
                'htmlOptions' => array(
                    'size' => '10',
                    'class' => 'form-control  form_empty centered date',
                ),
                'options' => array(
                    'dateFormat' => 'dd/mm/yy',
                    'showOn' => 'focus',
                    'showOtherMonths' => true,
                    'selectOtherMonths' => true,
                    'changeMonth' => true,
                    'changeYear' => true,
                    'showButtonPanel' => true,
                    'closeText' => Yii::t('ablock', 'Очистить'),
                    'beforeShow' => 'js:
                                function( input ) {
                                    setTimeout(function() {
                                        var clearButton = $(input ).datepicker( "widget" ).find( ".ui-datepicker-close" );
                                        clearButton.unbind("click").bind("click",function(){ $.datepicker._clearDate( input );});
                                    }, 1 )}',
                ),
            ),
                true) ?>

我使用此代码是为了让用户输入日期。但是,它接受 0 值。例如,如果用户输入不完整的日期,例如0d/mm/yyyy(这是不正确的日期),它将接受它为真。如果用户输入错误的值,我不需要允许。我该怎么做?

【问题讨论】:

  • 你在模型中添加验证规则了吗?

标签: javascript php yii yii1.x


【解决方案1】:

我没有找到任何只接受完整日期的参数。建议的解决方法:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-15
    • 2014-11-08
    • 2015-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-05
    • 2016-04-17
    相关资源
    最近更新 更多