how do you manually call js validation for a specific field?

Hello,

Does anyone know how to manually validate a specific field using jquery/js?

I need to manually trigger validation for a field when a user changes a dropdown a dropdown via jquery/js.

I don’t want to validate the whole form just a specific field.

If you know how to validate the whole form can you post it too?

Any help would be appreciated!!!

Add beforeValidate in CActiveForm and validate the form


$form = $this->beginWidget('CActiveForm',

        array(

                'id' => 'contact-form',

                'enableAjaxValidation' => true,

                'clientOptions' => array(

                        'validateOnSubmit' => true,

                        'beforeValidate' => 'js:beforeValidatefn',

                ),

        )

);

$js = "function beforeValidatefn(form){ 

 // do you validation here

 }";

Yii::app()->clientScript->registerScript('contact-form-beforeValidate', $js);



Thanks for the reply. I need this for yii2 and just for a specific field i.e.




$('#useParentAddress').change(function() {

	

tell YII2 to validate fields CITY, STATE, POSTAL CODE


   });



i just did a .blur() function on the field and let Yii do it. I would like to know the proper way to do this.




$('#useParentAddress').change(function() {

$("#companies-city,#companies-state,#companies-zip,#companies-country").blur();

   });