//函数名：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 notchinese(str){ 
var reg=/[^A-Za-z0-9_]/g 
     if (reg.test(str)){ 
     return (false); 
     }else{ 
return(true);     } 
} 

//检查电话号码
function isTel(str){
  var reg = /^(((\()?\d{2,4}(\))?[-(\s)*]){0,2})?(\d{7,8})$/;   
  if(reg.test(str))// 电话号码格式正确   
  return true;
  else //号码格式错误
  return false;
}

function check_validate1(value){ 
//定义正则表达式部分 
var reg = /^\d+$/; 
if( value.constructor === String ){ 
var re = value.match( reg ); 
return true; 
} 
return false; 
} 

//////////////
//检测注册用户
/////////////

function form1_reg()
{
if(document.form1.username.value=="") 
{ 
alert("用户名不能为空。"); 
document.form1.username.focus();
return false; 
} 


if ((fucCheckLength(document.form1.username.value)<3)||(fucCheckLength(document.form1.username.value)>8))
{
alert("用户名至少3位，不要超过8位");
document.form1.username.focus();
return false;
}


//用户名只能为数字、字母和下滑线组成
if (notchinese(document.form1.username.value)==false)
{
alert("用户名只能为数字、字母和下滑线组成");
document.form1.username.focus();
return false;
}

if ((fucCheckLength(document.form1.pwd.value)<6)||(fucCheckLength(document.form1.pwd.value)>10))
{
alert("密码至少6位，不要超过10位");
document.form1.pwd.focus();
return false;
}

if(document.form1.pwd.value=="") 
{ 
alert("密码不能为空。"); 
document.form1.pwd.focus();
return false; 
} 

if (document.form1.check_pwd.value!=document.form1.pwd.value)
{
alert ("两次密码不相同,请从新输入。");
//document.form1.check_pwd.value=''; 
document.form1.check_pwd.focus();
return false;
}


if(document.form1.contact.value=="") 
{ 
alert("联系人不能为空。"); 
document.form1.contact.focus();
return false; 
}

if(document.form1.region.value=="") 
{ 
alert("地区区号不能为空。"); 
document.form1.region.focus();
return false; 
}

if (isTel(document.form1.phone.value)==false)
{
alert("您输入的电话号码有误，请重新输入.");
document.form1.phone.focus();
return false;
}

if(document.form1.email.value.length=="")
  {
    alert("Email不能为空!");
    document.form1.email.focus();
    return false;
   }

if(document.form1.email.value.length!=0)
  {
    if (document.form1.email.value.charAt(0)=="." ||        
         document.form1.email.value.charAt(0)=="@"||       
         document.form1.email.value.indexOf('@', 0) == -1 || 
         document.form1.email.value.indexOf('.', 0) == -1 )
     {
      alert("请输入正确的Email");
      document.form1.email.focus();
      return false;
      }
   }

if(document.form1.com.value=="") 
{ 
alert("公司全称不能为空。"); 
document.form1.com.focus();
return false; 
}

if(document.form1.com_short.value=="") 
{ 
alert("公司简称不能为空。"); 
document.form1.com_short.focus();
return false; 
}

if(document.form1.s1.value=="-1") 
{ 
alert("公司地址不能为空"); 
document.form1.s1.focus();
return false; 
} 

if(document.form1.com_address.value=="") 
{ 
alert("详细地址不能为空。"); 
document.form1.com_address.focus();
return false; 
}

if (check_validate1(document.form1.com_fund.value)==false)
{
alert("注册资金只能为数字!");
document.form1.com_fund.focus();
return false;
}

if (document.form1.che.value==false)
{
alert("验证码不能为空!");
document.form1.che.focus();
return false;
}

}
