ActiveForm and afterValidate events

With the following ActiveForm config:

<?php $form = ActiveForm::begin([
	'id' => 'register-form',
    'options' => [
        'class' => 'validate-form',
    ],
	'enableClientValidation' => true,
	'enableAjaxValidation' => false,
	'validateOnSubmit' => true,
	'validateOnBlur' => true,
	'validateOnChange' => true,
]); ?>

// JS afterValidate function
$('.validate-form').on('afterValidate', function (event, messages, errorAttributes) {
    // do something special

    return false;
});

Currently the afterValidate() gets triggered on any validation event. How can I differentiate between the events validateOnSubmit, validateOnBlur and validateOnChange?

Basically, I only want my afterValidate() function to get triggered on submit.

I am not sure if I understand correctly. But have you tried the “submit” event?

  <script>
  // JS afterValidate function
$('.validate-form').on('submit', function (event, messages, errorAttributes) {
    // do something special
alert("aaa")
    return false;
});
</script>

If you only have 1 form I recommend to use the ID instead of the class like this:

$('#register-form')....