function Zip_onChange(zfield)
{   
	var strInput = zfield.value;
	var blnResult;
	
	if(strInput.length > 0)
	{		
		blnResult = Zip_Validate(strInput);
		
        	if(blnResult == false)
        	{
             		return "failed";
        	}
        	else
        	{
        		if(blnResult == true)
        		{
        			//do nothing
        		}
        		else
        		{
        			zfield.value = blnResult;
        		}
        	}        
	}
	return "ok";
}


function Zip_Validate(strInput)
{
	if(strInput.length == 0)
		{return true;}

	if(strInput.length != 5) 
	{
		alert("Zip Code should be 5 digits only - Please Re-enter!")
		return false;
	}
	
	for(y=0;y!=5;y++)
		{
			if(strInput.charCodeAt(y) < 48 || strInput.charCodeAt(y) > 57)
			{
				cmsg = "Zip Code needs digit instead of '" + strInput.charAt(y) + "' - Please Re-enter!";
				alert(cmsg);
				return false;
			}
		}
	
	
	return true;		
}


