【发布时间】: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