form validation before ajax call

Hi All,

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

Regards

Ilakya

Hi,

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

Thanks

Hi

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

Regards

Ilakya

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


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

so the form declaration should look something like this;


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

	'id'=>'order-form',

	'enableAjaxValidation'=>true,

	'clientOptions'=>array(

        'validateOnSubmit'=>true,

    ),

)); ?>