Skip to content

Instantly share code, notes, and snippets.

@robhimself82
Created January 1, 2012 11:21
Show Gist options
  • Save robhimself82/1547056 to your computer and use it in GitHub Desktop.
Save robhimself82/1547056 to your computer and use it in GitHub Desktop.
jQuery/AJAX Email Validation
$("#contact_form").validate({
submitHandler: function(form) {
$.ajax({
type: "POST",
url: "util/misc_func.php",
data: {
action: "validate_domain",
email: $("#form_email").val()
},
success: function(output) {
// If the domain exists we'll see "true."
if (output == "true") {
// If any validation errors are showing get rid of them.
$("#form_email").parent().find(".error").remove();
// Submit the form.
form.submit();
} else {
$("#form_email").parent().append(domainError);
}
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment