Using jQuery Validation-Engine v2.2. Ajax validation works correctly inline. But when I want to call it separately before submitting the form, it always returns true, even if the validation succeeds.
<input type="text" name="EmailAddress" id="EmailAddress" value=""
title="Email Address" maxLength="50" size="50"
class="validate[required,custom[email],ajax[ajaxEmailCheck]] register_input word_count"/>
$("#EmailAddress").validationEngine("validate");
I understand that is it supposed to return true if the validation fails. But this also returns true if it succeeds. The inline validation works perfectly. Could it be the asynchronous aspect of the ajax validation in effect here? How would I do this for a single field?
The reason I want to do this in the submit "again" is because some of our customers IGNORE the validation and the form is being submitted anyway. The form really should not submit if ANY validation fails. Not sure why that is happening, either.
It seems that any ajax validations are not fired when submitting the form, Only the other inline validations are firing.
I currently have the trigger set to the default blur because I want them to know when they are going through the fields if they make an error.
Any ideas on how to handle this situation with the ajax validation?
What I ended up doing was making the validation for that field a function call and doing a non-async ajax call in i. This works to prevent the form from submitting if the ajax call fails.
<input type="text" name="EmailAddress" id="EmailAddress" value=""
title="Email Address" maxLength="50" size="50"
class="validate[required,custom[email],funcCall[checkEmail]] register_input word_count"/>
function checkEmail(field, rules, i, options){
var url = "/api/AjaxEmailCheck/";
var data = field.attr("id") + "=" + field.val();
var msg = undefined;
$.ajax({
type: "GET",
url: url,
cache: false,
dataType: "json",
data: data,
async: false,
success: function(json) {
if(!json[1]) {
msg = json[2];
}
}
});
if(msg != undefined) {
return msg;
}
}
It seems there are still some issue with ajax validation in this plugin.