unobtrusive validation with custom validator that requires ajax post
I'm using ASP.NET MVC with unobtrusive validation. I need to add a new custom validation attribute with client-side validation, which is fine (I've already got some of those defined). The problem is that in the client side validation, I need to make an ajax call to check if the input is valid.
In MVC, you add client-side validators with addMethod:
But the function you define needs to return a boolean, and doing an ajax post is aysnc, which breaks that.
According to jQuery validator and a custom rule that uses AJAX there are 2 options - either use async:false in the ajax call or add a remote to the validate method. BUT, async:false is depcrated and I can't use remote because I'm using unobtrusive validation.
Has anyone got any better solutions to this?