yii\validators\RegularExpressionValidator::clientValidateAttribute PHP Method

clientValidateAttribute() public method

public clientValidateAttribute ( $model, $attribute, $view )
    public function clientValidateAttribute($model, $attribute, $view)
    {
        $pattern = Html::escapeJsRegularExpression($this->pattern);
        $options = ['pattern' => new JsExpression($pattern), 'not' => $this->not, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language)];
        if ($this->skipOnEmpty) {
            $options['skipOnEmpty'] = 1;
        }
        ValidationAsset::register($view);
        return 'yii.validation.regularExpression(value, messages, ' . Json::htmlEncode($options) . ');';
    }

Usage Example

 public function clientValidateAttribute($model, $attribute, $view)
 {
     $js = parent::clientValidateAttribute($model, $attribute, $view);
     if (!$this->enableIdn) {
         return $js;
     }
     PunycodeAsset::register($view);
     return "value = punycode.toASCII(value); {$js}";
 }
All Usage Examples Of yii\validators\RegularExpressionValidator::clientValidateAttribute