H
H
HellWalk2018-02-16 15:14:36
Yii
HellWalk, 2018-02-16 15:14:36

How to create custom JS event on successful form validation?

The work of forms can be described in simple two points:
1. Submitting the form
2. Result of form
processing 2 seconds, and the visitor may get the impression that nothing is working.
It is necessary when you click "submit", if the js-validation went well, the form was replaced with a loader-picture, and then, after 1-2 seconds, with the message "your form has been submitted"
I tried to look for where js form validation takes place in Yii2 ... I killed several hours, but did not figure it out. On the other hand, even if I find that, for example, it goes into yii.validation.js, this file cannot be edited, because it is needed to work with all forms.
Has anyone faced a similar problem? How did they decide?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Fedorov, 2018-02-16
@qonand

You can implement this functionality with js form events

V
Vadim Palgov, 2018-02-16
@iparfeon

There is an afterValidate event, the easiest way is to hang it up.

$('#form').on('afterValidate', function (e) {
    $('#loader').show();
    return true;
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question