I added a custom validation method to validate a password. However, it does not matter if the JSON I get is:
{"success":true}
or:
{"success":false}
The field password never validates.
$(document).ready(function () {
// Ad custom validation
$.validator.addMethod('authenticate', function (value) {
$.getJSON("./json/authenticate.do", { password: value }, function (json) {
return (json.success == true) ? true : false;
}
);
}, 'Wrong password');
$('form#changePasswordForm').validate({
rules: {
repeat_new_password: { equalTo: "#new_password" },
password: { authenticate: true }
}, submitHandler: function (form) {
$(form).ajaxSubmit({
dataType: "json",
success: function (json) {
alert("foo");
}
});
}
});
});
Any idea, what I am doing wrong?