Client Validation error does not prevent submit & ajax request


I use Yii client validation to validate some inputs and when there is an error in the user input, Yii client Validation does not prevent submit and does not prevent ajax request. I use grid widget "carvw-grid" and when user click submit button its make ajax request to update "carvw-grid" content with resluts. I want to prevent submit and ajax request when there is a client validation error.

here is my script code:

Yii::app()->clientScript->registerScript('search', "




$('.myresult').slideUp().delay(3000).queue(function() {






$('.search-form form').submit(function(){

    $.fn.yiiGridView.update('carvw-grid', {

        data: $(this).serialize()


    return false;



and here is my form

<?php $form=$this->beginWidget('CActiveForm', array(







    'clientOptions' => array('validateOnSubmit'=>true, 'validateOnType'=>true),

)); ?>

and here is my submit button

<div class="row buttons">

    <?php echo CHtml::submitButton('search',array('class'=>'search-button')); ?>


and here is my grid


    $this->widget('zii.widgets.grid.CGridView', array(











How can i prevent submit and ajax request on client validation errors?

Solved by using ‘afterValidate’,

thank you