public validate method for activeform

I’ve got an ActiveForm with client validation enabled and want to submit it using ajaxSubmitButton();

The problem is the submit button will happily fire regardless of the state of validation.

I think a callable validate() function would be good (could only work for client side validation).

It would display any errors then return a boolean value indicating if the form is valid.

This would allow the use of beforeSend in the ajax button.

Hi :)

Did you find the solution for this ? If Yes can you plz plz plz post ?

you can use afterValidate option.


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

function refresh_gridview(form, data, hasError)


if (!hasError) {

	$.fn.yiiGridView.update('$gridview_id', {

		data: $(form).serialize()





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








afterValidate is not getting fired for me when I am using ajaxSubmitButton !

So I came up myself with the simplest solution to this problem here