Yii CActiveForm Date Check

Checking the date for the Text Date field does not work.

http://sky-walker.net/temp/test/yii/testdate/index.php?r=site/login

The “required” check is performed if I asked it as needed.

What I want the text box to do is either red or green when the form is submitted, and also when the focus is lost with ajax. If it turns red, an error message should also appear.

From login.php

<div class="row">
    <?php echo $form->labelEx($model,'textDate'); ?>
    <?php echo $form->textField($model,'textDate'); ?>
    <?php echo $form->error($model,'textDate'); ?>
</div>

From LoginForm.php

public $textDate;

From the rules ()

...array('textDate', 'date', 'format'=>'d/M/yyyy'),...
+1
source share
1 answer

You do not have ajax validation in your form. You have a JavaScript validation check. If you look with Firebug, then you will see that nothing is communicating with the server => you only have a js check, you are not checking the model.

, ajax

'enableAjaxValidation' => true,
'clientOptions' => array(
        'validateOnSubmit' => true,
        'validateOnChange' => true,
),
+3

All Articles