﻿<!--

var strClearString = "";

function checkState()
{
	var arrStateIndex = new Array(4, 1, 28, 34, 30, 3)
	
	with (document.surveyform)
	{
		for (var i=0; i<=5; i++)
		{
			if (state.selectedIndex == arrStateIndex[i])
			{
				city.value = state[arrStateIndex[i]].value;
				break;
			}
			else
			{
				city.value = "城市";
			}
		}
	}
}

function IsValidSerialNo(strString, strType) 
{
	//  check for valid numeric strings with period
	var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";
	var strChar = "";
	var blnResult = true;
	var i = 0;
	
	strClearString = "";

	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.value.length && blnResult == true; i++)
	{
	   strChar = strString.value.charAt(i);
	   
	   if (strChar != " ")
	   {
		   if (strValidChars.indexOf(strChar) == -1)
		   {
			  blnResult = false;
			  break;
		   }
	   }

	   if (strChar != "-" && strChar != " ")
	   {
			strClearString += strChar;
	   }
	}

	if (blnResult)
	{
		switch (strType)
		{
			case "0" :
				if (strClearString.length == 14 || strClearString.length == 6)
				{
					blnResult = true;
				}
				else
				{
					blnResult = false;
				}
				break;
			case "1" :
				if (strClearString.length == 8 || strClearString.length == 12)
				{
					blnResult = true;
				}
				else
				{
					blnResult = false;
				}
				break;
			case "2" :
				if (strClearString.length == 4 || strClearString.length == 5 || strClearString.length == 8 || strClearString.length == 11 || strClearString.length == 12 || strClearString.length == 13 || strClearString.length == 14 || strClearString.length == 17)
				{
					blnResult = true;
				}
				else
				{
					blnResult = false;
				}
				break;
			default :
				{
					blnResult = false;
				}
		}
	}

	return blnResult;
}

//-->

