enable submit only after ajax validation

hello, i have a really big form and it starts with the submit button being disabled. i would like the submit button to get automatically enabled after all fields are filled out.

so far i just tried to make a jquery function that checks what is filled and what not, but that is really tedious, as the form is big, there are many alternative fields and fields that are dependent on values in other fields.

i was wondering if there is maybe a way to trigger an ajax validation for the whole form after changing any of the input fields and enable or disable the submit button according to the validation result.

Have the same problem. Does anybody how to deal with it?


did some testing for you and achieved what you’re trying to achieve with this code

//JavaScript function to test if collection is empty

//NOTE: I guess you could also use $.isEmptyObject

function isEmptyData(data){

	for(var i in data){


			return false;


	return true;


// CActiveForm widget initialization

// you wanted ajax validation and form validated on input change:

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

	'enableAjaxValidation' => true,

	'clientOptions' => array(

		'afterValidateAttribute' => 'js:function(form, attribute, data, hasError){if(isEmptyData(data)){$(\'[type=submit]\', form).attr(\'disabled\',false)}}',

		'validateOnChange' => true,


)); ?>

Hope it’ll help,


Have the same problem - disabling Submit button but this code seems not working… :(

I made copy-paste of js code and added ‘clientOptions’ part to ajax form - or I need to change something more?

check this forum