Skip to content

Instantly share code, notes, and snippets.

@sharkyak
Last active December 16, 2016 15:39
Show Gist options
  • Save sharkyak/05e0309cb7b44d563cda to your computer and use it in GitHub Desktop.
Save sharkyak/05e0309cb7b44d563cda to your computer and use it in GitHub Desktop.
отправка формы ajax email send
$('#Popup-Form').submit(function() {
if (testPhone('#Phone')) {
$.ajax({
type: "POST",
url: "mail.php",
data: $(this).serialize()
}).done(function() {
$(this).find("input").val('');
$('#Popup-Form').trigger("reset");
document.location.href = 'thankyou.html';
});
} else {
document.getElementById('Phone').style.border = '1px solid red';
document.getElementById('Phone').style.color = 'red';
}
return false;
});
function testPhone(phoneName) {
var re = /^[\d\(\)\+ -]+$/;
return re.test($(phoneName).val());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment