﻿
var txtName;
var txtEmail;
var txtPhone;
var txtComment;
	
function sendForm(){
	var dataString = 'userName='+ txtName + '&userEmail=' + txtEmail + '&userPhone=' + txtPhone + '&userComments=' + txtComment;  
	
	$.ajax({  
	   type: "POST",  
	   url: "contact.php",  
	   data: dataString,  
	   success: function() {  
		 $("#contact").hide();
		 $("#success").show();
	   }  
	 });  
}


function validateForm(){

	txtName = $("#txtName").val();
	txtEmail = $("#txtEmail").val();
	txtPhone = $("#txtPhone").val();
	txtComment = $("#txtComment").val();
	
	if(txtName == "" || txtName == "Name"){
		alert("Name is Required");
		$("#txtName").focus();
		return false;
	}
		
	if(txtPhone == "" || txtPhone == "Phone"){
		alert("Phone is Required");
		$("#txtPhone").focus();
		return false;
	}
	
	if(txtEmail == "" || txtEmail == "Email"){
		alert("Email is Required");
		$("#txtEmail").focus();
		return false;
	}

	sendForm();
}






