form validation before ajax call

Hi All,

I want to fire up form validation when I click the ajax there a way to do this in yii.




you can search this string on google "yii + ajax based validation example" than go through first 5-6 help sites.



I know that it is possible to have ajax validation that is triggered on blur event of a form element.But if a user doesn’t touch even a single form element and then he clicks on submit button which is a CHtml::ajaxSubmitButton… Form validation is not done…

Is there a solution for this



Hi ,

Have you tried using :

echo CActiveForm::validate(array($model));

in your controller?

to trigger ajax validation when the submit button is clicked, add the following to the form declaration in your view


so the form declaration should look something like this;

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






)); ?>