Yii Framework Forum: form validation before ajax call - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

form validation before ajax call

#1 User is offline   Ilakya 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 02-March 12

Posted 02 March 2012 - 05:54 AM

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
0

#2 User is offline   Pravin Gajera 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 137
  • Joined: 25-October 11
  • Location:India

Posted 03 March 2012 - 04:21 AM

Hi,

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

Thanks
0

#3 User is offline   Ilakya 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 02-March 12

Posted 21 March 2012 - 01:31 AM

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
0

#4 User is offline   talby101 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 26-August 10
  • Location:Wales

Posted 21 March 2012 - 02:53 AM

Hi ,

Have you tried using :
echo CActiveForm::validate(array($model));


in your controller?


View PostIlakya, on 21 March 2012 - 01:31 AM, said:

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

0

#5 User is offline   atari_icon 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 25-January 12

Posted 07 June 2012 - 06:26 AM

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,
    ),
)); ?>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users