I am using a postcode lookup to fill in some forms fields when they type in a certain field. Now if the form has been submitted and the autocompleted fields are empty, they are marked as errored. If I then use the auto complete to fill them in, the error messages don't disappear as the field has not been focused or blurred.
Is there a way to force re-validation of the fields?
I have tried the following but nothing happens (the console is logged):
pca.on("load", (type, id, control) => {
control.listen("populate", address => {
console.log('populate'); // this gets hit
$('.pca-form').validate(); // this does nothing
});
});
I am using the unobtrusive version of validate if that makes a difference
As it turns out you call .valid()
instead of .validate()
:
$('.pca-form').valid(); // this re-validates all fields