Javascript Success Method On Form Ajaxsubmit?

I’m wondering whether it’s possible to add a success catch when CActiveForm successfully validates.

For example with the following code:


    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(


        'enableAjaxValidation' => true,

        'enableClientValidation' => false,

        'focus' => array($model, 'username'),

        'clientOptions' => array(

            'validateOnSubmit' => true,


            'beforeValidate'=>'js:function(){$("#registration-form").parent().addClass("loading");return true;}',

            'afterValidate'=>'js:function(){$("#registration-form").parent().removeClass("loading");return true;}',



        'htmlOptions' => array(

            'class' => 'form registration-forms',

            'id' => 'registration-form',





In this example I’m using TbActiveForm instead of CActiveForm but in either case the success is not called when the form fields are all valid. Is it possible to catch this n the Javascript? Does the responding JSON from the controller require something in order to do this? I don’t want the page to reload in this case.



Try to give the function name and check

‘clientOptions’ => array(

                                                                             'validateOnSubmit' =&gt; true,	

		                                                                     'validateOnChange' =&gt; false,				

		                                                               'afterValidateAttribute' =&gt; 'js:yourfunction1()',	

		                                                                        'afterValidate' =&gt; 'js:yourfunction2()',


I could do that but it would give me the same result. I want to catch the event that the submitted form is VALID.