title: Yii2 - ActiveForm and afterValidate events
body: <p>I am using ActiveForm with the <code>afterValidate()</code> event, however currently the <code>afterValidate()</code> gets triggered on any validation event. How can I differentiate between the events <code>validateOnSubmit</code>, <code>validateOnBlur</code> and <code>validateOnChange</code>?</p>
  <p>Basically, I only want my <code>afterValidate()</code> function to get triggered on submit. Here is my code:</p>
  <p>PHP:</p>
  <pre><code>&lt;?php $form = ActiveForm::begin([
      'id' =&gt; 'register-form',
      'options' =&gt; [
          'class' =&gt; 'validate-form',
      ],
      'enableClientValidation' =&gt; true,
      'enableAjaxValidation' =&gt; false,
      'validateOnSubmit' =&gt; true,
      'validateOnBlur' =&gt; true,
      'validateOnChange' =&gt; true,
  ]); ?&gt;
  </code></pre>
  <p>JS:</p>
  <pre><code>// JS afterValidate function
  $('.validate-form').on('afterValidate', function (event, messages, errorAttributes) {
      $('.error-popup').show();
  
      return false;
  });
  </code></pre>
  <p>HTML:</p>
  <pre><code>&lt;div class=&quot;error-popup&quot;&gt;Please review the errors in the form below.&lt;/div&gt;
  </code></pre>
  <p>As you can see in my <code>afterValidate()</code> function above, an error popup is shown if there are validation errors. However I only want this to error popup to appear if there are any validation errors when the user submits the form.</p>
  <p>If there is a validation error on blur/change then the normal inline validation should occur without any error popup.</p>
  <p>From my understanding, <code>beforeSubmit</code> event is only triggered when validation has passed.</p>