Last active
December 16, 2016 15:39
-
-
Save sharkyak/05e0309cb7b44d563cda to your computer and use it in GitHub Desktop.
отправка формы ajax email send
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
$('#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