I am trying to create a special ZIP code validation based on database values. Therefore I am checking the values by ajax:
jQuery.validator.addMethod("validate_country_from", function(value, element)
{
$.ajax({
type: "POST",
url: "ajax.php",
data: "action=validate_countryzip&direction=1&zip=" +
escape(document.getElementById("zip_from").value) + "&country=" +
escape(document.getElementById("country_from").value),
async: false
}).done(function(msg)
{
if(msg == "true")
{
return true;
}
else
{
return false;
}
});
}, addressError);
And I am assigning the function in the rules by these rules:
zip_from: {
required: true,
validate_country_from: true
},
country_from: {
required: true,
validate_country_from: true
},
The ajax request is working fine, and it is done synchronous, the returned value is also correct but still my validation is telling me that there is an error on the two fields.
I hope someone can help...