Open viktorix opened 8 years ago
I think that is how it is supposed to work.
If the ajax call fails, you expect the validation error to run.
If the ajax call succeeds, you expect the validation success to run. The result of the validation might be that the email address appears to be invalid, but this is still a "success" as far as the validator is concerned.
Unless I'm mistaken :)
Yea, that might be the case. If it is, maybe it's the comment that explains what the function does needs to be re-worded: if email is invalid
That's just the sample code - agreed the comment could be misleading
It looks like there's a bug with how error validation_error function works. https://github.com/mailgun/validator-demo/blob/master/index.html#L88
$('#status').html(error_message);
does not fire.The "Address is invalid." check and error message does work properly, but it is fired inside validation_success function as the last remaining "else" condition.
You can easily test this by removing
$('#status').html(error_message);
and testing validator. You'll see it still works just fine. This is a problem because if we want to do something else when email is invalid, let's say addClass it does not work.