I'm using Jquery validator on a simple email input form.
<form name="form" submit.delegate="submit()">
<div class="form-group">
<label for="ea">Email</label>
<input type="email" value.bind="emailaddy" class="form-control" id="ea" name="ea" />
</div>
<button type="submit" id="submitbutton"class="btn btn-default">Submit</button>
</form>
My validator rules are handling the required and valid email and my custom error messages show up correctly. On submit I want to check if the email already exists. The webApi call works but I don't know how to set the Jquery validator errorClass on my emailaddy element.
submit() {
var vm = this;
return vm.webApi.emailExists(vm.emailaddy)
.then(function (data) {
if (data === true) {
console.log("email exists, don't submit");
// set errorClass for the email element
}
else {
console.log("email not found, submit");
// do the submit
}
});
}