validator-demo
validator-demo copied to clipboard
No validation on first call
Hi,
The first call I make to mailgun_validator doesn't really happen. I've checked the network log and there is no validation requests. I then focus on the element that calls the validation, blur and the call is correctly made.
This is my code:
$("#email").blur(validateEmail);
var validateEmail = function() {
var email = $("#email");
if (email.val() !== "") {
email.mailgun_validator({
api_key: 'XXXXXXX',
in_progress: in_progress_callback, // called when request is made to validator
success: success_callback, // called when validator has returned
error: validation_error, // called when an error reaching the validator has occured
});
};
I have logs in every method and I see that after the first call neither success_callback nor validation_error are called. Any ideas?
Same issue here, the first call does never work.
If you look at the code, it binds to an element object and then only runs the validator once the input is blurred. This was posing a problem for me, as well, so I created my own repository inspired by this one that will let you call the method whenever you like and receive a callback response via AJAX. You can view it here.