WEB FORM API
Simply copy & paste the script below into your project for real-time email validation.
$('form').submit(function (event) {
var email = $('#email').val();
$.getJSON(
'https://email.perfectvalidation.com/api/validate/' + encodeURIComponent(email) + '/'
).done(function (info) {
if (info && info.Summary) {
// you may want to adjust thresholds according to your needs, default is 0.1
if (info.Summary.validity > 0.1 && info.Summary.deliverability > 0.1) {
// the email is valid
} else {
// the email is NOT valid
switch (info.Summary.errors[0].code) {
case 1: /* email address must contain @ */ break;
case 2: /* mailbox is not specified before @ */ break;
case 3: /* domain is not specified after @ */ break;
case 4: /* invalid domain name */ break;
case 5: /* invalid mailbox, see info.Summary.errors[0].message for more details */ break;
}
event.preventDefault();
}
} else {
// something went wrong during the API request, consider valid
}
}).fail(function () {
// something went wrong during the API request, consider valid
});
});