Ok so this is a really simple scenario which I can't figure out since I've just started with MVC. I have created a custom password validator to use both client and server side. For the meantime the client-side validator does nothing but check the length (it will do more than this once I get it working). The server-side validation works fine. This is the client side implementation
$.validator.unobtrusive.adapters.add("password",
function (options) {
options.rules['password'] = {};
options.messages['password'] = options.message;
}
);
$.validator.addMethod("password", function (value, element, params) {
if (value.length < 8 || value.length > 15) {
return false;
}
return true;
});
I only want this validator to fire when the form is submitted.
Currently, as soon as you start typing it tells you that your password is invalid until the password meets the length requirements. I want it to act like the standard 'Required' validators I have on other form fields where they only validate the input once the form is submitted.