function hiddonsubmit(){
  imagesub.style.display="none";
  messagesvalue.style.display="";
}
function showsubmit(){
  imagesub.style.display="";
  messagesvalue.style.display="none";
}
//函数名：chksafe
//功能介绍：检查是否含有"'",'\\',"/"
//参数说明：要检查的字符串
//返回值：0：是  1：不是
function chksafe(a)
{	
	return 1;
/*	fibdn = new Array ("'" ,"\\", "、", ",", ";", "/");
	i=fibdn.length;
	j=a.length;
	for (ii=0;ii<i;ii++)
	{	for (jj=0;jj<j;jj++)
		{	temp1=a.charAt(jj);
			temp2=fibdn[ii];
			if (tem';p1==temp2)
			{	return 0; }
		}
	}
	return 1;
*/	
}

//函数名：chkemail
//功能介绍：检查是否为Email Address
//参数说明：要检查的字符串
//返回值：0：不是  1：是
function chkemail(a)
{	var i=a.length;
	var temp = a.indexOf('@');
	var tempd = a.indexOf('.');
	if (temp > 1) {
		if ((i-temp) > 3){
			
				if ((i-tempd)>0){
					return 1;
				}
			
		}
	}
	return 0;
}

//函数名：fucPWDchk
//功能介绍：检查是否含有非数字或字母
//参数说明：要检查的字符串
//返回值：0：含有 1：全部为数字或字母
function fucPWDchk(str)
{
  var strSource ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var ch;
  var i;
  var temp;
  
  for (i=0;i<=(str.length-1);i++)
  {
  
    ch = str.charAt(i);
    temp = strSource.indexOf(ch);
    if (temp==-1) 
    {
     return 0;
    }
  }
  if (strSource.indexOf(ch)==-1)
  {
    return 0;
  }
  else
  {
    return 1;
  } 
}
//函数名：fucCheckNUM
//功能介绍：检查是否为数字
//参数说明：要检查的数字
//返回值：1为是数字，0为不是数字
function fucCheckNUM(NUM)
{
	var i,j,strTemp;
	strTemp="0123456789";
	if ( NUM.length== 0)
		return 0
	for (i=0;i<NUM.length;i++)
	{
		j=strTemp.indexOf(NUM.charAt(i));	
		if (j==-1)
		{
		//说明有字符不是数字
			return 0;
		}
	}
	//说明是数字
	return 1;
}

//函数名：chkspc
//功能介绍：检查是否含有空格
//参数说明：要检查的字符串
//返回值：0：是  1：不是
function chkspc(a)
{
	var i=a.length;
	var j = 0;
	var k = 0;
	while (k<i)
	{
		if (a.charAt(k) != " ")
			j = j+1;
		k = k+1;
	}
	if (j==0)
	{
		return 0;
	}
	
	if (i!=j)
	{ return 2; }
	else
	{
		return 1;
	}
}

//函数名：fucCheckTEL
//功能介绍：检查是否为电话号码
//参数说明：要检查的字符串
//返回值：1为是合法，0为不合法
function fucCheckTEL(TEL)
{
	var i,j,strTemp;
	strTemp="0123456789-()# ";
	for (i=0;i<TEL.length;i++)
	{
		j=strTemp.indexOf(TEL.charAt(i));	
		if (j==-1)
		{
		//说明有字符不合法
			return 0;
		}
	}
	//说明合法
	return 1;
}

//函数名：fucCheckLength
//功能介绍：检查字符串的长度
//参数说明：要检查的字符串
//返回值：长度值
function fucCheckLength(strTemp)
{
	var i,sum;
	sum=0;
	for(i=0;i<strTemp.length;i++)
	{
		if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
			sum=sum+1;
		else
			sum=sum+2;
	}
	return sum;
}

function form1_onsubmit() 
{
if (chkspc(document.form1.name.value)==0)
	{	alert("请填写您的登录名。");
		document.form1.name.focus();
		return false;
	}
	
if ((chksafe(document.form1.name.value)==0)||(fucCheckLength(document.form1.name.value)>30))
	{	alert("请填写正确的登录名。");
		document.form1.name.focus();
		return false;		
	}
	
	if (chkspc(document.form1.truename.value)==0)
	{	alert("请填写您的真实姓名。");
		document.form1.truename.focus();
		return false;
	}
	
	if ((chksafe(document.form1.truename.value)==0)||(fucCheckLength(document.form1.truename.value)>30))
	{	alert("请填写正确的姓名。");
		document.form1.truename.focus();
		return false;		
	}	
	
	if (fucCheckLength(document.form1.password.value)<4) 
	{	alert("密码必须大于4位")
		document.form1.password.focus();
		return false;
	}
	
	if ((chksafe(document.form1.password.value)==0)||(fucCheckLength(document.form1.password.value)>18))
	{	alert("请填写正确密码。")
		document.form1.password.focus();
		return false;		
	}
	if (document.form1.password.value != document.form1.repassword.value)
	{	alert("确认密码与密码不同！")
		document.form1.password.focus();
		return false;		
	}
	
	if (chkspc(document.form1.wenti.value)==0)
	{	alert("请填写您的密码提问。");
		document.form1.wenti.focus();
		return false;
	}
	if ((chksafe(document.form1.wenti.value)==0)||(fucCheckLength(document.form1.wenti.value)>50))
	{	alert("请填写正确的密码提问。");
		document.form1.weiti.focus();
		return false;		
	}
	if (fucCheckLength(document.form1.daan.value)<4) 
	{	alert("提示问题答案必须大于4位")
		document.form1.daan.focus();
		return false;
	}
	if (chkspc(document.form1.daan.value)==0)
	{	alert("请填写密码提示问题答案。");
		document.form1.daan.focus();
		return false;
	}
	if ((chksafe(document.form1.daan.value)==0)||(fucCheckLength(document.form1.daan.value)>50))
	{	alert("请填写正确的密码提示问题答案。");
		document.form1.daan.focus();
		return false;		
	}

	if ((chkspc(document.form1.email.value)==0) || (chkemail(document.form1.email.value)==0))
	{	alert ("请填写正确的e-mail地址。");
		document.form1.email.focus();
		return false;
	}
	if ((chksafe(document.form1.email.value)==0)||(fucCheckLength(document.form1.email.value)>40))
	{	alert ("请填写正确的e-mail地址。");
		document.form1.email.focus();
		return false;		
	}

	if ((document.form1.tel.value=='') || (chkspc(document.form1.tel.value)==0) || (fucCheckLength(document.form1.tel.value)>30)||(fucCheckTEL(document.form1.tel.value)==0))
	{
		alert("您的常用电话号码填写有误。");
		document.form1.tel.focus();
		return false;
	}
	
	if (chkspc(document.form1.address.value)==0)
	{	alert ("请填写您的地址。");
		document.form1.address.focus();
		return false;
	}
	if ((chksafe(document.form1.address.value)==0)||(fucCheckLength(document.form1.address.value)>200))
	{	alert ("请填写正确的地址。");
		document.form1.address.focus();
		return false;		
	}
	if (chkspc(document.form1.pcode.value)==0)
	{	alert ("请您填写邮政编码。");
		document.form1.pcode.focus();
		return false;
	}
	
		if ((chksafe(document.form1.pcode.value)==0)||(fucCheckLength(document.form1.pcode.value)>6))
	{	alert ("请填写正确的邮政编码。");
		document.form1.pcode.focus();
		return false;		
	}
	
	for (lgth=0;lgth<=document.form1.password.value.length;lgth++)
		{	if ( (document.form1.password.value.charCodeAt(lgth)>128)  || (document.form1.password.value.charAt(lgth)=="'") )
			{	alert("请不要输入中文密码或者单引号！");
				document.form1.password.focus();
				return false;
			}
		}
}
