title: How to live validate from in yii2?
body: <p>How can I live validate my form without clicking form button?</p>
  
  <p>Model:</p>
  
  <pre><code>public function rules() {
      return [
          ['CodeKargah', 'CodeKargah_check'],
          // ...
          // ...
          // ...
      ];
  }
  
  public function CodeKargah_check($attribute) {
      $zero = substr($this - &gt; $attribute, 0, 1);
      $len = strlen((string)($this - &gt; $attribute));
      if ($zero == '0' &amp;&amp; $len == 10) {
          return null;
      }
      else {
          $this - &gt; addError($attribute, Yii::t('app', 'First number must be zero'));
      }
  } 
  </code></pre>
  
  <p>After submitting form it works</p>