0

I have got the form and I do some things after validate with ajax on the page. I do it with .on('afterValidate', function () And all works good, but only first time. After it form is not working, if I will work with it second time. How I can refresh frontend validation and work with this form again and again on submit? Just .on('submit' - is not good idea, because form works twice in this mode (form submitted two times, because validation from backend will be).

1 Answers1

0

I think for AJAX-based validation you should use another event:

ajaxComplete event is triggered after completing an AJAX request for AJAX-based validation. The signature of the event handler should be:

function (event, jqXHR, textStatus)

where

  • event: an Event object

  • jqXHR: a jqXHR object

  • settings: the status of the request ("success", "notmodified", "error", "timeout", "abort", or "parsererror").

Can't find it in official docs, you can see it here in var = events { ... }

So try .on('ajaxComplete', function (event, jqXHR, textStatus) { ... }) instead of .on('afterValidate', function ({ ... }).

arogachev
  • 31,868
  • 6
  • 105
  • 113