I have a form in a modal, the user has to complete the form (otherwise validation will display the required fields error messages), then click the submit input type, it does
This is how I deal with remote validation.
if (form.find('[data-val-remote]').length > 0) {
form.find('[type="submit"]').on("click enter", function (evt) {
var interval = setInterval(function () {
// keep check if there are any remote pending then prevent submit button from click
if (Object.keys($('form').validate().pending).length) {
evt.preventDefault();
} else {
// if all remote responded then check form valid or not
if (!form.valid()) {
// if isvalid then stop interval
clearInterval(interval);
}
// if form valid then submit and stop interval
form.submit();
clearInterval(interval);
}
// loop 100ms
}, 100);
return false;
});
}