Created
July 25, 2014 11:49
-
-
Save AstakhovArtem/b8a65fe15c76e38c2b11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validation.add( | |
'validate_unique_email', | |
'This email is already in use! Please log in in order to proceed', | |
function(value){ | |
var url = validationUniqueEmail + '?email=' + encodeURIComponent(value); | |
var ok = false; | |
new Ajax.Request(url, { | |
method: 'get', | |
asynchronous: false, | |
onSuccess: function(transport) { | |
var obj = response = eval('(' + transport.responseText + ')'); | |
validateTrueEmailMsg = obj.status_desc; | |
if (obj.ok === false) { | |
Validation.get('validate-email').error = validateTrueEmailMsg; | |
ok = false; | |
} else { | |
ok = true; /* return true or false */ | |
} | |
}, | |
onComplete: function() { | |
if ($('advice-validate-email-email')) { | |
$('advice-validate-email-email').remove(); | |
} | |
if ($('advice-validate-email-email_address')) { | |
$('advice-validate-email-email_address').remove(); | |
} | |
if ($('advice-validate-email-billing:email')) { | |
$('advice-validate-email-billing:email').remove(); | |
} | |
if ($('advice-validate-email-shipping:email')) { | |
$('advice-validate-email-shipping:email').remove(); | |
} | |
if ($('advice-validate-email-_accountemail')) { | |
$('advice-validate-email-_accountemail').remove(); | |
} | |
} | |
}); | |
return ok; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment