How To Exclude File Input Fields In Ajax Validation

I have created the ajax validation and it performs well for each field except the file input field. It keeps alerting me in red. I want to ask if there are any way to exclude file input fields in ajax validation?

Here is my rule:


public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('id_product, id_color, store, try_store', 'required'),

			array('id_product, id_color, store, try_store', 'numerical', 'integerOnly'=>true),

			array('path_one, path_two, path_three, path_four', 'length', 'max'=>200,'on'=>'insert,update'),

			array('path_one, path_two, path_three, path_four', 'file','types'=>'jpeg,jpg,png,gif','allowEmpty'=>false,'on'=>'insert'),

			array('path_one, path_two, path_three, path_four', 'file','types'=>'jpeg,jpg,png,gif','allowEmpty'=>true,'on'=>'update'),

			// The following rule is used by search().

			// Please remove those attributes that should not be searched.

			array('id, path_one, path_two, path_three, path_four, id_product, id_color, store, try_store', 'safe', 'on'=>'search'),

		);

	}

How did you define your file function?




public function files($attribute,$params)

{


}



As you have figured out, you can’t validate or upload files with AJAX. You can either set allowEmpty to true, or you can pass all attributes except the file input to CActiveForm::validate, but maybe someone else has a better solution.