Created
April 14, 2017 09:50
-
-
Save canonkko/f563e42a99c6a39124c84f5714a13e14 to your computer and use it in GitHub Desktop.
E-mail Ajax validate form
This file contains 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
//E-mail Ajax validate form | |
$("#callback").validate({ | |
ignore: ":hidden", | |
rules: { | |
name: { | |
required: true, | |
minlength: 2 | |
}, | |
phone: { | |
required: true | |
} | |
}, | |
messages: { | |
name: { | |
required: "Обязательно для заполнения" | |
}, | |
phone: { | |
required: "Обязательно для заполнения" | |
} | |
}, | |
focusCleanup: true, | |
focusInvalid: false, | |
submitHandler: function (form) { | |
$.ajax({ | |
type: "POST", | |
url: "mail.php", //Change | |
data: $(form).serialize() | |
}).done(function() { | |
$.fancybox.open('<div class="message"><h2>Спасибо!</h2><p>Ваша заявка отправлена успешно!</p><p>Мы перезвоним вам через 15 минут.</p></div>'); | |
// alert("Thank you!"); | |
setTimeout(function() { | |
// Done Functions | |
$(form).trigger("reset"); | |
$.fancybox.close(); | |
$.fancybox.close("#popup"); | |
}, 3000); | |
}); | |
return false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment