Problem With Field Error Messages

Hello, guys. I use this setting:


   'enableAjaxValidation' => true,

            'enableClientValidation'=>true,

            'clientOptions'=>array(

                'validateOnSubmit'=>true,

                'validateOnChange'=>true,

            ),

            'htmlOptions' => array('enctype' => 'multipart/form-data'),

Ajax validation works fine. Model validation works fine. BUt…

Error messages displayed before the user entered something. It are generating on page refresh, not while the user is typing wrong data in field, as I expected.

Is it a normal, or i got mistake in my code?

And please tell me, what i have to do to change this.

up!

Check your code for handling the form submit and presentation. You may be validating the form on presentation rather than when the user submits. Make sure you do something like:




if (Yii::app()->request->isAjaxRequest) {

    //process form validation here

}



If you focus on a form field which is below an input which is required but not filled the required input will display an error. That’s normal behaviour, a form should be filled from the top down.