I have the a form with the following validation setup:
$('#form').validate({
onfocusout: false,
onkeyup: false,
onclick: false,
success: function (){
$('#username').addClass('input-validation-confirmation');
}
});
$('#username').rules("add", {
onfocusout: false,
onkeyup: false,
required: true,
email: true,
remote: {
url: function,
type: 'GET',
dataType: 'json',
traditional: true,
data: {
username: function () {
return $('#username').val();
}
},
dataFilter: function (responseString) {
var response = jQuery.parseJSON(responseString);
currentMessage = response.Message;
if (response.State == 0) {
currentMessage = currentMessage + 0;
return false;
}
return 'true';
},
beforeSend: function (response) {
showLoadingIndicator($('#username'));
},
complete: function () {
hideLoadingIndicator($('#username'));
}
}
});
What this is attempting to do is use the same validation elements (in order to work with some other framework) to show both errors and success methods.
My problem is that the success method of my rule gets fired BEFORE the remote validation has completed. I tried setting the message several ways but the custom messages parameter doesn't seem to be called on validation success.
Does anyone know of other methods to use the validation error field for both success and error messages when using a mix of both remote and pattern validation rules?
Edit:
I now understand I was expecting a success event at the wrong time. I need an event that is fired once validation has completed (not submitted). Is there any such event?