
function ValidPhone(aphone)
{
	var valid = "0123456789";

		if(aphone=="")
		{
		alert("Phone number is required field!")
		return false
		}
		
		if(aphone.length != 10)
		{
		alert("Invalid phone number! Please try again.")
		return false
		}
		
		
		for (var i=0; i < aphone.length; i++)
		{
		temp = "" + aphone.substring(i, i+1);
		
		
			if (valid.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your phone.  Please try again.")
			return false;
			}
		}
		
	
		return true
}






function valid_date(field)
{
	if(field=="")
	{
	alert("Date of Birth required field!")
	return false;
	}
	
	

	var valid = "0123456789/";
	var slashcount = 0;

	if (field.length!=10) 
	{
	alert("Invalid date! The correct date format is like '01/01/2004'.   Please try again.")
	return false;
	}
		for (var i=0; i < field.length; i++)
		 {
		temp = "" + field.substring(i, i+1);
		if (temp == "/") 
		slashcount++;
			if (valid.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your date.  Please try again.")
			return false;
			}
		if (slashcount > 2) 
		{
		alert("Invalid Date!  The slash character should be used with a properly formatted 8 digits like  '01/01/2004'.   Please try again.")
		return false;
  		 }
		if((field.charAt(2)!= '/')||(field.charAt(5) != '/'))
		{
		alert("Invalid date! The slash character should be used with a properly formatted 8 digits like  '01/01/2004'.   Please try again.")
		return false;
		}
	}
	return true;


}

function valid_required(field)
{
	if(field=="") 
	{
	return false;
	}

	return true;
}


//function to check valid email address
function EmailValid(strEmail){
  validRegExp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
  strEmail = document.contact.email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      alert('A valid e-mail address is required.\nPlease amend and retry');
      return false;
    } 
    return true; 
}

