|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/serbaantik.com/public_html/theme/js/ |
Upload File : |
(function($) { "use strict";
function Selector_Cache() {
var collection = {};
function get_from_cache( selector ) {
if ( undefined === collection[ selector ] ) {
collection[ selector ] = $( selector );
}
return collection[ selector ];
}
return { get: get_from_cache };
}
var selectors = new Selector_Cache();
jQuery(document).ready(function ($) { // wait until the document is ready
$('#send').on('click', function(){ // when the button is clicked the code executes
$('.error').fadeOut('slow'); // reset the error messages (hides them)
var error = false; // we will set this true if the form isn't valid
var name = $('input#name').val(); // get the value of the input field
if(name == "" || name == " ") {
$('#err-name').fadeIn('slow'); // show the error message
error = true; // change the error state to true
}
var email_compare = /^([a-z0-9_.-]+)@([da-z.-]+).([a-z.]{2,6})$/; // Syntax to compare against input
var email = $('input#email').val(); // get the value of the input field
if (email == "" || email == " ") { // check if the field is empty
$('#err-email').fadeIn('slow'); // error - empty
error = true;
}else if (!email_compare.test(email)) { // if it's not empty check the format against our email_compare variable
$('#err-emailvld').fadeIn('slow'); // error - not right format
error = true;
}
if(error == true) {
$('#err-form').slideDown('slow');
return false;
}
var data_string = $('#ajax-form').serialize(); // Collect data from form
$.ajax({
type: "POST",
url: $('#ajax-form').attr('action'),
data: data_string,
timeout: 6000,
error: function(request,error) {
if (error == "timeout") {
$('#err-timedout').slideDown('slow');
}
else {
$('#err-state').slideDown('slow');
$("#err-state").html('An error occurred: ' + error + '');
}
},
success: function() {
$('#ajax-form').slideUp('slow');
$('#ajaxsuccess').slideDown('slow');
}
});
return false; // stops user browser being directed to the php file
}); // end click function
});
})(jQuery);