// April 25, 2006
// validPostalZip()
// validPostalCode()
// validZipCode()

// \b Matches a word boundary, that is, the position between a word and a space. For example, 'er\b' matches the 'er' in "never" but not the 'er' in "verb".  
// \B Matches a nonword boundary. 'er\B' matches the 'er' in "verb" but not the 'er' in "never".  
// \d Matches a digit character. Equivalent to [0-9].  
// \D Matches a nondigit character. Equivalent to [^0-9].  
// \s Matches any white space character including space, tab, form-feed, and so on. Equivalent to [ \f\n\r\t\v]. 
// \S Matches any non-white space character. Equivalent to [^ \f\n\r\t\v].  
// \w Matches any word character including underscore. Equivalent to '[A-Za-z0-9_]'.  
// \W Matches any nonword character. Equivalent to '[^A-Za-z0-9_]'.  

// also add the following within the tag
// onblur="this.value=this.value.toUpperCase();this.value=this.value.replace(/(\s+)/gi,'');"

//*******************************************************************************'
// valid a Postal Code

function validPostalZip(strValue) // as Boolean
{
	var TorF; // True or False
	
	// test for US Zip Code
	TorF = validZipCode(strValue);
	
	// if the value didnt pass the US syntax test, try the Cdn syntax test
	if (TorF == false)
	{
		
		// test for Canadian Postal Code
		TorF = validPostalCode(strValue)
	}
	
	// return the return value
	return TorF;
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version

function validpostalzip(strValue) // as Boolean
{
	return validPostalZip(strValue)
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version

function ValidPostalZip(strValue) // as Boolean
{
	return validPostalZip(strValue)
}

//*******************************************************************************'
// valid a Zip Code

function validZipCode(strValue) // as Boolean
{
	var objRegExp;
	
	// create the regular express for US zip codes 
	// format = 99999 or 99999-9999
	objRegExp = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
	
	//return the test results
	return objRegExp.test(strValue);
	
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version

function validzipcode(strValue) // as Boolean
{
	return validZipCode(strValue)
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version

function ValidZipCode(strValue) // as Boolean
{
	return validZipCode(strValue)
}

//*******************************************************************************'
// valid a Postal Code

function validPostalCode(strValue) //as Boolean
{
	var objRegExp;
	
	// create the regular express for Canadian postal codes
	// form of = Z5Z-5Z5, Z5Z 5Z5 or Z5Z5Z5 (case -insensitive)
	objRegExp = /^\D{1}\d{1}\D{1}[\- ]?\d{1}\D{1}\d{1}$/i;
	
	// run test
	return objRegExp.test(strValue);

}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version

function validpostalcode(strValue) // as Boolean
{
	return validPostalCode(strValue)
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version

function ValidPostalCode(strValue) // as Boolean
{
	return validPostalCode(strValue)
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// example

/*
<script language="javascript">
function validateForm1(formObj)
{
	//Canada = 26
	if(formObj.drpCountryID.value == "26" && validPostalCode(formObj.ZipCode.value) == false)
	{
		alert("Invalid Postal Code");
		formObj.ZipCode.focus();
		return false;
	}
	//US = 144
	else if(formObj.drpCountryID.value == "144" && validZipCode(formObj.txtZipCode.value) == false)
	{
		alert("Invalid Zip Code");
		formObj.ZipCode.focus();
		return false;
	}
	else
	{
		return true;
	}
}
</script>
*/
