victorjonsson / jQuery-Form-Validator

[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.
972 stars 476 forks source link

No Error Message showed for async validation triggered manually #697

Closed tonprince closed 2 years ago

tonprince commented 6 years ago

I am using the async custom validator on an input which is triggered manually:

$.formUtils.addAsyncValidator({
    loadHotelsByProduct(trip, function(hotels) {
      done(hotels.indexOf(value) != -1);
    });
  });

 pickupHotelNode.validate(function(valid, elem) {
 });

The problem is that there is no error message showed after the done callback is invoked, even the validation result is false.

tonprince commented 6 years ago

My workaround is to call validateInputOnBlur explicitly after done call.

loadHotelsByProduct(trip, function(hotels) {
  done(hotels.indexOf(value) != -1);
  $input.validateInputOnBlur($.formUtils.LANG, $('form.booking').get(0).validationConfig, true);
});