//April 4, 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)
	{
		
		//test for Canadian Postal Code
		torf = validPostalCode(strValue)
	}
	
	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 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 at = 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)
}
