client side validation in custom validation rule

Hello everyone,

In my model I have a custom validation rule, however this does not work client side Can I get help please?




public function rules()

{

    return [

        [['support'], 'custom_validation_rule']

    ];

}


public function custom_validation_rule($attribute, $params){

    if($attribute == '1'){

        $this->addError($attribute,'Error');

    }

}



You have to create a standalone validator.

http://www.yiiframework.com/doc-2.0/guide-input-validation.html#standalone-validators

And then you can write clientValidateAttribute() to implement client-side validation.

http://www.yiiframework.com/doc-2.0/guide-input-validation.html#standalone-validators

Ok thank you very much. I will test it and I will tell you. Thank you very much again.