// JavaScript Document
//////////////////////////////////////// 
// JavaScript function to validate US 
// phone number: 
// 
// (c) 2003 
// No restrictions have been placed on the use 
// of this code 
// 
// Updated Friday Jan 9 2004 to optionally ignore
// the area code:
//
// Input: a single string parameter and an
// optional boolean variable (default=true)
// Output: boolean true(1) or false(0) 
// 
// The function will return true for any 
// alphanumeric string with the following 
// sequence of characters: 
// a single 
// open parentheses [optional], any number of 
// spaces [optional], 3 digits (area 
// code), any number of spaces [optional], a 
// single close parentheses [optional], a single 
// dash [optional], any number of spaces 
// [optional], 3 digits, any number of spaces 
// [optional], a single dash [optional], any 
// number of spaces [optional], 4 digits. 
// 
//////////////////////////////////////// 
function check_usphone(phonenumber,useareacode) 
{ 
	if(!useareacode)
		useareacode=1;
	
	if((phonenumber.match(/^[(]{0,1}[ ]*[0-9]{3,3}[ ]*[)]{0,1}[-]{0,1}[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}$/)==null)/* && ((useareacode!=1) && (phonenumber.match(/^[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/)==null))*/) 		
		return false; 
	
	return true; 
}

function check_standard_usphone(phonenumber,useareacode) 
{ 
	if(!useareacode)
		useareacode=1;
	
	if((phonenumber.match(/^[0-9]{3,3}[-]{1,1}[0-9]{3,3}[-]{1,1}[0-9]{4,4}$/)==null)/* && ((useareacode!=1) && (phonenumber.match(/^[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/)==null))*/) 		
		return false; 
	
	return true; 
}

function check_uszipcode(zipcode) 
{ 
	if (zipcode.match(/^[0-9]{5,5}$/) == null)
		return false; 
	
	return true; 
}

function check_first_name(name) 
{ 
	if (name.match(/^[a-zA-Z]{1,1}[a-zA-Z- ]*$/) == null)
		return false; 
	
	return true; 
}

function check_middle_name(name) 
{ 
	if (name.match(/^[a-zA-Z- ]*$/) == null)
		return false; 
	
	return true; 
}

function check_last_name(name) 
{ 
	if (name.match(/^[a-zA-Z]{1,1}[a-zA-Z- .]*$/) == null)
		return false; 
	
	return true; 
}

function check_street_address(street) 
{ 
	if (street.match(/^[a-zA-Z0-9]{1,1}[a-zA-Z0-9- #.]*$/) == null)
		return false; 
	
	return true; 
}

function check_city(city) 
{ 
	if (city.match(/^[a-zA-Z]{1,1}[a-zA-Z- ]*$/) == null)
		return false; 
	
	return true; 
}

function check_email(email) 
{ 
	if (email.match(/^[.0-9a-zA-Z]+[@]{1,1}[a-zA-Z]{1,1}[0-9a-zA-Z]*[.]{1,1}[a-zA-Z]+$/) == null)
		return false; 
	
	return true; 
}