wp/wp-content/themes/themeforest-2964855-scrn-responsive-single-page-portfolio/SCRN/js/contact-form.js
author ymh <ymh.work@gmail.com>
Wed, 06 Nov 2013 03:21:17 +0000
changeset 0 d970ebf37754
permissions -rwxr-xr-x
first import

jQuery(document).ready(function() {
	
	//if submit button is clicked
	jQuery('.contact-form #submit').click(function () {		
		
		//Get the data from all the fields
		var name = jQuery('input[name=name]');
		var email = jQuery('input[name=email]');
		var website = jQuery('input[name=website]');
		var comment = jQuery('textarea[name=comment]');

		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field
		if (name.val()=='') {
			name.addClass('hightlight');
			return false;
		} else name.removeClass('hightlight');
		
		if (email.val()=='') {
			email.addClass('hightlight');
			return false;
		} else email.removeClass('hightlight');
		
		if (comment.val()=='') {
			comment.addClass('hightlight');
			return false;
		} else comment.removeClass('hightlight');
		
		//disabled all the text fields
		jQuery('.text').attr('disabled','true');
		
		//show the loading sign
		jQuery('.loading').show();

		jQuery.post("../wp-content/themes/SCRN/index.php", { name : name.val(), email : email.val(), comment : comment.val(), submit : "yes" }, function() {
						
			jQuery('.form').fadeOut('slow');					

			jQuery('.done').fadeIn('slow');

			jQuery('.contact-form form').fadeOut('slow');

		});
					
		return false;
						
		//cancel the submit button default behaviours
	});	
});