EyeTrackVR-Docs/docs/assets/js/main.js
ZanzyTHEbar 50aec9f18a update
- Added JQuery, owlcarousel.min.js, jquery validate, popper.min.js, and threejs support.
- Added PHP script to send email from form front-end
- Will add form next
2022-06-06 21:32:13 +02:00

71 lines
1.7 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();
});