$(document).ready(function() {			
	var form = $('#quoteform');
	var fname = $('#fname');
	var lname = $('#lname');
	var email = $('#email');
	var phone = $('#phone');	
	var phone = $('#ph_acode');	
	var phone = $('#ph_ext');	
	var phone = $('#ph_body');	
	var phone = $('#phone2');	
	var phone = $('#ph_acode2');	
	var phone = $('#ph_ext2');	
	var phone = $('#ph_body2');	
	var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;	   	
	
	$("#phone").keypress(function (e){ 
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
		//display error message
		//$("#errmsg").html("Digits Only").show().fadeOut("slow"); 
		return false;
	  }	
	});
	
	$("#ph_acode").keypress(function (e){ 
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
		//display error message
		//$("#errmsg").html("Digits Only").show().fadeOut("slow"); 
		return false;
	  }	
	});
	
	$("#ph_ext").keypress(function (e){ 
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
		//display error message
		//$("#errmsg").html("Digits Only").show().fadeOut("slow"); 
		return false;
	  }	
	});
	
	$("#ph_body").keypress(function (e){ 
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
		//display error message
		//$("#errmsg").html("Digits Only").show().fadeOut("slow"); 
		return false;
	  }	
	});
	
	$("#phone2").keypress(function (e){ 
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
		//display error message
		//$("#errmsg").html("Digits Only").show().fadeOut("slow"); 
		return false;
	  }	
	});
	
	$("#ph_acode2").keypress(function (e){ 
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
		//display error message
		//$("#errmsg").html("Digits Only").show().fadeOut("slow"); 
		return false;
	  }	
	});
	
	$("#ph_ext2").keypress(function (e){ 
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
		//display error message
		//$("#errmsg").html("Digits Only").show().fadeOut("slow"); 
		return false;
	  }	
	});
	
	$("#ph_body2").keypress(function (e){ 
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
		//display error message
		//$("#errmsg").html("Digits Only").show().fadeOut("slow"); 
		return false;
	  }	
	});
	
	form.submit(function(){							 						 
		if(fname.val() == ''){
			notifyMsg('Please enter your first name.');
			return false;
		}
		
		if(lname.val() == ''){
			notifyMsg('Please enter your last name.');
			return false;
		}
									 								 
		if(email.val() == ''){
			notifyMsg('Please enter your email.');
			return false;
		}
		
		if(filter.test(email.val())){
			//valid email						
		}else{
			notifyMsg('Error: Invalid email address.');			
			return false;
		}
		
		if(phone.val() == ''){
			notifyMsg('Please enter a phone number.');			
			return false;
		}								
		
		if(phone2.val() == ''){
			notifyMsg('Please enter a phone number.');			
			return false;
		}								
		
	});			
	
	function notifyMsg($txt){
		$('#errMsg').html('');
		$('#errMsg').html($txt);
	}
		
});	