mirror of
https://github.com/EyeTrackVR/EyeTrackVR-Docs.git
synced 2025-11-04 14:49:44 +08:00
67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
$(function () {
|
|
"use strict";
|
|
// Form
|
|
var contactForm = function () {
|
|
if ($("#contactForm").length > 0) {
|
|
$("#contactForm").validate({
|
|
rules: {
|
|
fname: "required",
|
|
lname: "required",
|
|
email: {
|
|
required: true,
|
|
email: true,
|
|
},
|
|
message: {
|
|
required: true,
|
|
minlength: 5,
|
|
},
|
|
},
|
|
messages: {
|
|
fname: "Please enter your first name",
|
|
lname: "Please enter your last name",
|
|
email: "Please enter a valid email address",
|
|
message: "Please enter a message",
|
|
},
|
|
/* submit via ajax */
|
|
submitHandler: function (form) {
|
|
var $submit = $(".submitting"),
|
|
waitText = "Submitting...";
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "php/send-email.php",
|
|
data: $(form).serialize(),
|
|
|
|
beforeSend: function () {
|
|
$submit.css("display", "block").text(waitText);
|
|
},
|
|
success: function (msg) {
|
|
if (msg == "OK") {
|
|
$("#form-message-warning").hide();
|
|
setTimeout(function () {
|
|
$("#contactForm").fadeOut();
|
|
}, 1000);
|
|
setTimeout(function () {
|
|
$("#form-message-success").fadeIn();
|
|
}, 1400);
|
|
} else {
|
|
$("#form-message-warning").html(msg);
|
|
$("#form-message-warning").fadeIn();
|
|
$submit.css("display", "none");
|
|
}
|
|
},
|
|
error: function () {
|
|
$("#form-message-warning").html(
|
|
"Something went wrong. Please try again."
|
|
);
|
|
$("#form-message-warning").fadeIn();
|
|
$submit.css("display", "none");
|
|
},
|
|
});
|
|
},
|
|
});
|
|
}
|
|
};
|
|
contactForm();
|
|
});
|