function checkform(theForm)
{

if (theForm.customer.value == "")
{
 alert("请在 姓名 域中输入值。");
 theForm.customer.focus();
 return (false);
}

if (theForm.customer.value.length < 2)
{
 alert("在 姓名 域中，请至少输入 2 个字符。");
 theForm.customer.focus();
 return (false);
}

if (theForm.customer.value.length > 8)
{
 alert("在 姓名 域中，请最多输入 8 个字符。");
 theForm.customer.focus();
 return (false);
}

if (theForm.certnum.value == "")
{
 alert("请在 身份证号码 域中输入值。");
 theForm.certnum.focus();
 return (false);
}

if (theForm.certnum.value.length < 15)
{
 alert("在 身份证号码 域中，请至少输入 15 个字符。");
 theForm.certnum.focus();
 return (false);
}

if (theForm.certnum.value.length > 18)
{
 alert("在 身份证号码 域中，请最多输入 18 个字符。");
 theForm.certnum.focus();
 return (false);
}

if (theForm.city.options[theForm.city.selectedIndex].value=="-1")
{
 alert("请选择您所在的城市。");
 //theForm.city.focus();
 return (false);
}


if (theForm.phonenum.value == "")
{
 alert("请在 联系电话 域中输入值。");
 theForm.phonenum.focus();
 return (false);
}

if (theForm.phonenum.value.length < 6)
{
 alert("在 联系电话 域中，请至少输入 6 个字符。");
 theForm.phonenum.focus();
 return (false);
}

if (theForm.email.value == "")
{
 alert("请在 E-mail 地址 域中输入值。");
 theForm.email.focus();
 return (false);
}

if (theForm.email.value.length < 3)
{
 alert("在 E-mail 地址 域中，请至少输入 3 个字符。");
 theForm.email.focus();
 return (false);
}

if (theForm.customerid.value == "")
{
 alert("请在 魔力会员账号 中输入值。");
 theForm.customerid.focus();
 return (false);
}


if (theForm.ccustomerid.value == "")
{
 alert("请确认您的魔力会员账号。");
 theForm.customerid.focus();
 return (false);
}

if (!( theForm.customerid.value ==  theForm.ccustomerid.value ))
{
 alert("确认魔力会员账号错误。");
 theForm.ccustomerid.focus();
 return (false);
}

if (checkCustomerid(theForm.customerid.value))  
	{

	  if (theForm.customerid.value.length<8)
	  {
      alert("魔力会员帐号最少8位。");
      theForm.customerid.focus();
      return (false);	  }

	  if (theForm.customerid.value.length>20)
	  {
      alert("魔力会员帐号最多20位。");
      theForm.customerid.focus();
      return (false);
	  }
	}
	else
	{
      alert("魔力会员帐号只允许英文字母及数字。");
      theForm.customerid.focus();
      return (false);
	}

return (true);

}

function checkCustomerid(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 false;
    }
  }
  if (strSource.indexOf(ch)==-1)
  {
    return false;
  }
  else
  {
    return true;
  } 


}

