function CheckPhoneNumber(PhoneNo,TagStr)

{

	// get rid of non-numerics

	var checkOK = new String("0123456789");

	var strNo = new String(PhoneNo.value);

	PhoneNo.value="";

	for ( i = 0; i < strNo.length; i++ )

	{

		ch = strNo.charAt(i);

		for (j = 0;  j < checkOK.length;  j++)

			if (ch == checkOK.charAt(j))

				break;

		if (j != checkOK.length)

		{

			PhoneNo.value=String(PhoneNo.value)+String(ch);

		}

	}





	// get rid of leading 1

	if ( ( PhoneNo.value.length == 11 ) && ( PhoneNo.value.charAt(0) == 1 ) )

	{

		PhoneNo.value = PhoneNo.value.substr(1,10);

	}



	if ( (PhoneNo.value.length != 0) && (PhoneNo.value.length < 10) )

	{

		alert("Please enter exactly 10 digits in \"" + TagStr + "\".");

		PhoneNo.focus();

		return (false);

	}



	if (PhoneNo.value.length > 10)

	{

		alert("Please enter exactly 10 digits in \"" + TagStr + "\".");

		PhoneNo.focus();

		return (false);

	}



	var checkStr = PhoneNo.value;

	var allValid = true;

	var decPoints = 0;

	for (i = 0;  i < checkStr.length;  i++)

	{

		ch = checkStr.charAt(i);

		for (j = 0;  j < checkOK.length;  j++)

		if (ch == checkOK.charAt(j))

		break;

		if (j == checkOK.length)

		{

			allValid = false;

			break;

		}

	}

	if (!allValid)

	{

		alert("Please enter only digits in \"" + TagStr + "\".");

		PhoneNo.focus();

		return (false);

	}



	if ( checkStr.length == 10 )

	{

		if ( checkStr.charAt(0) < '2' )

		{

			alert("The first digit of the area code in \"" + TagStr + "\" cannot be a '1' or '0'");

			PhoneNo.focus();

			return (false);

		}



		if ( checkStr.charAt(3) < '2' )

		{

			alert("The first digit of the prefix in \"" + TagStr + "\" cannot be a '1' or '0'");

			PhoneNo.focus();

			return (false);

		}



		if ( checkStr.substring(0,3) == "900" )

		{

			alert("The area code in \"" + TagStr + "\" cannot be '900'");

			PhoneNo.focus();

			return (false);

		}

	}





	else

		return (true);




}
function CheckPhoneNumber2	(PhoneNo,TagStr)

{

	// get rid of non-numerics

	var checkOK = new String("0123456789");

	var strNo = new String(PhoneNo.value);

	PhoneNo.value="";

	for ( i = 0; i < strNo.length; i++ )

	{

		ch = strNo.charAt(i);

		for (j = 0;  j < checkOK.length;  j++)

			if (ch == checkOK.charAt(j))

				break;

		if (j != checkOK.length)

		{

			PhoneNo.value=String(PhoneNo.value)+String(ch);

		}

	}





	// get rid of leading 1

	if ( ( PhoneNo.value.length == 11 ) && ( PhoneNo.value.charAt(0) == 1 ) )

	{

		PhoneNo.value = PhoneNo.value.substr(1,10);

	}



	if ( (PhoneNo.value.length != 0) && (PhoneNo.value.length < 10) )

	{

		alert("Please enter exactly 10 digits in \"" + TagStr + "\".");

		PhoneNo.focus();

		return (false);

	}



	if (PhoneNo.value.length > 10)

	{

		alert("Please enter exactly 10 digits in \"" + TagStr + "\".");

		PhoneNo.focus();

		return (false);

	}



	var checkStr = PhoneNo.value;

	var allValid = true;

	var decPoints = 0;

	for (i = 0;  i < checkStr.length;  i++)

	{

		ch = checkStr.charAt(i);

		for (j = 0;  j < checkOK.length;  j++)

		if (ch == checkOK.charAt(j))

		break;

		if (j == checkOK.length)

		{

			allValid = false;

			break;

		}

	}

	if (!allValid)

	{

		alert("Please enter only digits in \"" + TagStr + "\".");

		PhoneNo.focus();

		return (false);

	}



	if ( checkStr.length == 10 )

	{

		if ( checkStr.charAt(0) < '2' )

		{

			alert("The first digit of the area code in \"" + TagStr + "\" cannot be a '1' or '0'");

			PhoneNo.focus();

			return (false);

		}



		if ( checkStr.charAt(3) < '2' )

		{

			alert("The first digit of the prefix in \"" + TagStr + "\" cannot be a '1' or '0'");

			PhoneNo.focus();

			return (false);

		}



		if ( checkStr.substring(0,3) == "900" )

		{

			alert("The area code in \"" + TagStr + "\" cannot be '900'");

			PhoneNo.focus();

			return (false);

		}

	}





	else

		return (true);




}