Anton Abramov
Anton Abramov

Reputation: 2331

Yii2 ActiveForm ajax validation callback

Is there any way to get errors after ajax validation in js? I need to create some custom modals with errors info. So i think i need some sort of callback function...

Any weird options, like binding submit event on form works bad, i can't get info about filling required fields, for example.

Upvotes: 0

Views: 2459

Answers (1)

nornik
nornik

Reputation: 21

You can use ActiveForm JavaScript API.

Example:

$('#form').on('afterValidate', function (event, fields, errors) {
    if (errors.length > 0) {
        alert('Errors exists');
    }
});

Upvotes: 2

Related Questions