Validate Form Via Js But Not Server-Side Ajax

Hi, I am using ajaxSubmitButton to submit a form. I want to know how to validate the form in client-side, I mean just use js, rather than server-side ajax.

I’m digging for a long time, still cannot figure it out. Please help me!!!

Below is the form

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

	'id' => 'questions-form',

	'enableAjaxValidation' => false,


foreach ($questions as $question):



	<p><?php echo $question['description'];?></p>

	<?php foreach ($question['options'] as $option) :?>

	<label class="radio">

	<input type="radio" name='<?php echo "q".$question["id"];?>' id='<?php echo "q".$question["id"];?>' value='<?php echo $option["opt"]?>'>

	<?php echo $option['val'];?>


	<?php endforeach;?>



<?php endforeach;?>

<input type="hidden" name="quiz_id" value="<?php echo $quiz_id;?>">


echo GxHtml::ajaxSubmitButton(

		Yii::t('app', 'Submit'),



			'update' => '#content-swap'



		array('class'=>'btn', 'id'=>'qz'.uniqid()));



you can set the client side validtion property to true and should work

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

        'id' => 'questions-form',

        'enableAjaxValidation' => false,



Hi thanks, but the $question is not a model. It is an item in the array of $questions, which is generated by combining several tables in the database, so i cannot use rules from Active Model.

I think one possible solution might be to write a js by hand. but first i have to know how to pause the submission before the form is validated.

Can you help me with this?

Loot at the Validation plugin from bAssistance: