
//函数名：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;
}



//函数名：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;
	}
}
function isNumberString (InString,RefString){
	if(InString.length==0) return (false);
	for (Count=0; Count < InString.length; Count++){
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)  
		return (false);
	}
	return (true);
	}
  
/*function checkhz() 
    { 
        var check=/[^\u4E00-\u9FA5]/g; 
        var txtcheck=document.getElementById("username").value; 
        if(txtcheck!="") 
        { 
            if(check.test(txtcheck)) 
            { 
                alert("只能输入汉字"); 
                return false; 
            } 
            else 
            { 
                alert("通过"); 
                return true; 
            } 
        } 
        else 
        { 
            alert("测试内容不能为空"); 
            return false; 
        } 
    }
*/
function checkinput()
{


    if (chkspc(document.myform.username.value)==0)
	{	alert("请您填写姓名!");
		document.myform.username.focus();
		return false;
	}
		if (document.myform.username.value.length<3)
	{	alert("请正确填写您的姓名，不能小于3位！");
		document.myform.username.focus();
		return false;
	}
	
	if (document.myform.username.value.length>20)
	{	alert("请正确填写您的姓名，不能超过20位！");
		document.myform.username.focus();
		return false;
	}
	
    if (chkspc(document.myform.mobile.value)==0)
	{	alert("请您填写手机号码!");
		document.myform.mobile.focus();
		return false;
	}
    if (document.myform.mobile.value!=0)
	{   
	   if(isNumberString(document.myform.mobile.value,"1234567890")!=1){
              alert("手机号码只能包括数字！");
	          document.myform.mobile.focus();
	          return false;
        }
        if (document.myform.mobile.value.length!=11)
	      {	  alert("手机号码应为11位！");
		      document.myform.mobile.focus();
		      return false;
	       }
  
	}
	
/*   if (chkspc(document.myform.phone.value)!=0)
	{
	
		　　if (fucCheckNUM(document.myform.phone.value)==0)
	　　　　{	alert("其他电话可不填写，如要填写，电话号码必需是数字!");
		　　　　document.myform.phone.focus();
		　　　　return false;
	         }
	}*/
 	
    if (chkemail(document.myform.e_mail.value)==0)
	{	alert("请填写您的邮箱!");
		document.myform.e_mail.focus();
		return false;
	}

	
    if (chkemail(document.myform.e_mail.value)!=0)
	{

			 if (document.myform.e_mail.value.length>30)
	          {	  alert("邮箱可不填写，如要填写，不能超过30位！");
		          document.myform.e_mail.focus();
		          return false;
	          }

	}
  return (true);
}


