// JavaScript Document
function checkempty(obj,msg)
{
	
	if(obj.value=="")
	{
		alert(msg);
		obj.focus();
		return false;
	}
}
//Validating name or consumer
function isText(obj, msg) {
	  var regex =/^[A-Za-z\s/]+$/;
	   if (regex.test(obj.value)==true)
	  {
	  
		return true;
	  }
	  else{
		
		alert(msg);
		obj.value="";
		obj.focus();
		return false;
	  }
	}
// is extetension number	
	function isExt(obj, msg) {
	  var regex =/^[0-9]{0,4}$/;
	   if (regex.test(obj.value)==true)
	  {
	  
		return true;
	  }
	  else{
		
		alert(msg);
		obj.value="";
		obj.focus();
		return false;
	  }
	}
//phone and fax
function isPhone(obj, msg) {
	  var regex =/^[0-9]\d{10}$/;
	   if (regex.test(obj.value)==true)
	  {
	  
		return true;
	  }
	  else{
		
		alert(msg);
		obj.value="";
		obj.focus();
		return false;
	  }
	}
//is address
function isAdress(obj, msg) {
	  
	  var regex =/^[a-zA-Z0-9\s.\-/#]+$/;
	   if (regex.test(obj.value)==true)
	  {
	  
		return true;
	  }
	  else{
		
		alert(msg);
		obj.value="";
		obj.focus();
		return false;
	  }
	}
	//valid email
	function vemail(obj,msg) {

	  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;

	  if (regex.test(obj.value))

	  {

		return true;

	  }

	  else{

		alert(msg);

		obj.focus();

		return false;

	  }

	}
function chkform() {
	
	if(checkempty(document.form1.Name, "Contact Information: Enter Name ")==false) return false;
	if(isText(document.form1.Name, "Contact Information: Wrong Name")==false) return false;
	
if(checkempty(document.form1.Telephone, "Contact Information: Enter Phone ")==false) return false;
if(isPhone(document.form1.Telephone, "Contact Information: Wrong Phone Number ")==false) return false;
	
	
	if(isExt(document.form1.Ext, "Contact Information: Wrong Extension ")==false) return false;
	
	if(checkempty(document.form1.Fax, "Contact Information: Enter Fax ")==false) return false;
	if(isPhone(document.form1.Fax, "Contact Information: Wrong Fax Number ")==false) return false;
	
	if(checkempty(document.form1.Email, "Contact Information: Enter Email ")==false) return false;
	if(vemail(document.form1.Email, "Contact Information: Wrong Email ")==false) return false;
	
	if(checkempty(document.form1.Address, "Contact Information: Enter Adress ")==false) return false;
	if(isAdress(document.form1.Address, "Contact Information: Wrong Adress ")==false) return false;
	
	if(checkempty(document.form1.Tariff, "Contact Information: Enter Tariff ")==false) return false;
	if(checkempty(document.form1.MB, "Contact Information: Enter Monthly Bill ")==false) return false;
	alert("Thanks for your information")
	window.document.form1.submit()
	
	}	