mirror of
https://github.com/EyeTrackVR/EyeTrackVR-Docs.git
synced 2025-11-04 14:49:44 +08:00
- 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
71 lines
1.7 KiB
JavaScript
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();
|
|
|
|
}); |