<!--


function check(theForm)
{
	
	
  if(theForm.UserName.value =="" ){
    alert("請輸入姓名! ");
    theForm.UserName.focus();
    return(false);
  }
  else if(theForm.UserName.length > 30){
	  alert("輸入姓名太長(少於30 個字元)!");
	  theForm.UserName.focus();
	  return(false);
  }

  if(theForm.UserID.value==""){
	  alert("請輸入使用者帳號! ");
	  theForm.UserID.focus();
	  return(false);
  }

  if(!check_id(theForm.UserID.value)){
  	theForm.UserID.focus();
  	return(false);
  }

  if(theForm.PassWord.value.length < 6 ){
  	alert("密碼太短(最少6個字元)!");
  	theForm.PassWord.focus();
  	return(false);
  }
  else if(theForm.PassWord.value.length > 16 ){
  	alert("密碼太長(少於16個字元)!");
  	theForm.PassWord.focus();
  	return(false);
  }

  if(theForm.PassWord1.value!=theForm.PassWord.value ){
  	alert("輸入密碼不符 !");
  	theForm.PassWord1.focus();
  	return(false);
  }
  if(theForm.Address.value == ""){
  	alert("請輸入地址! ");
  	theForm.Address.focus();
  	return(false);
  }
  else if(theForm.Address.length > 250){
  	alert("請輸入地址(少於250個字元)");
  	theForm.Address.focus();
  	return(false);
  }
  if(theForm.TEL.value == ""){
  	alert("請輸入電話! ");
  	theForm.TEL.focus();
  	return(false);
  }
  else if(theForm.TEL.length > 25){
  	alert("請輸入電話(少於25字元)!");
  	theForm.TEL.focus();
  	return(false);
  }
  if(theForm.Country.value=="0"){
	  alert("請選擇國家! ");
	  theForm.Country.focus();
	  return(false);
	}

  if( theForm.e_mail.value.length == 0 ) {
    alert( "請輸入E-Mail!" );
    return false;
  } else {
    i = theForm.e_mail.value.indexOf( "@" );
    j = theForm.e_mail.value.indexOf( ".", i );
    k = theForm.e_mail.value.indexOf( "," );
    kk = theForm.e_mail.value.indexOf( " " );
    jj = theForm.e_mail.value.lastIndexOf( "." ) + 1;
    len = theForm.e_mail.value.length;
    if( ( i <= 0 ) || ( j <= 2 ) || ( k != -1 ) || ( kk != -1 ) || ( len - jj < 2 ) || ( len - jj > 3 ) ) { 
      alert( "E-Mail格式錯誤" );
      return false;
    }
  }

}


function check_id(id)
{
  	id = id.toLowerCase();
	if (id.length<5) {
		alert("使用者帳號太短!..");
		return false;
	}
	if (id.length>14) {
		alert("使用者帳號太長!");
		return false;
	}
  	if(id.charAt(0)<"a" || id.charAt(0)>"z") {
		alert("帳戶第一個字為英文或數字!");
		return false;
  	}
  	for(var i=0 ; i<id.length ; i++) {
  		if(id.charAt(i)!="_" &&
  	   	   (id.charAt(i)<"a" || id.charAt(i)>"z") &&
  	   	   (id.charAt(i)<"0" || id.charAt(i)>"9")) {
  	   		alert("帳號只能使用英文字母，數字，或者底線!");
	  	   	return false;
  		}
  	}
  	return true;
} 


function check_Dis(theForm)  //經銷商
{

  if(theForm.CompanyName.value == ""){
  	alert("請輸入公司名稱! ");
  	theForm.CompanyName.focus();
  	return(false);
  }	
  else if(theForm.CompanyName.length > 70){
  	alert("公司名稱太長(少於70 個字元)!");
  	theForm.CompanyName.focus();
  	return(false);
  }	
  
  if(theForm.UserName.value == ""){
  	alert("請輸入姓名! ");
  	theForm.UserName.focus();
  	return(false);
  }
  else if(theForm.UserName.length > 30){
  	alert("輸入姓名太長(少於30 個字元)! ");
  	theForm.UserName.focus();
  	return(false);
  }

  if(theForm.UserID.value==""){
  	alert("請輸入使用者帳戶! ");
  	theForm.UserID.focus();
  	return(false);
  }

  if(!check_id(theForm.UserID.value)){
  	theForm.UserID.focus();
  	return(false);
  }

  if(theForm.PassWord.value.length < 6 ){
  	alert("密碼太短(最少 6 個字元)!");
  	theForm.PassWord.focus();
  	return(false);
  }
  else if(theForm.PassWord.value.length > 16 ){
  	alert("密碼太長(少於16 個字元)!");
  	theForm.PassWord.focus();
  	return(false);
  }

  if(theForm.PassWord1.value!=theForm.PassWord.value ){
  	alert("輸入密碼不符!");
  	theForm.PassWord1.focus();
  	return(false);
  }
  
  if(theForm.Address.value == ""){
  	alert("請輸入地址! ");
  	theForm.Address.focus();
  	return(false);
  }
  else if(theForm.Address.length > 250){
  	alert("輸入地址太長(少於 250 個字元)!");
  	theForm.Address.focus();
  	return(false);
  }
  
  if(theForm.Country.value=="0"){
  	alert("請選擇國家! ");
  	theForm.Country.focus();
  	return(false);
  }
  
  if(theForm.TEL.value == ""){
  	alert("請輸入電話! ");
  	theForm.TEL.focus();
  	return(false);
  }
  else if(theForm.TEL.length > 25){
  	alert("輸入電話太長(少於 25字元)!");
  	theForm.TEL.focus();
  	return(false);
  }


  if( theForm.e_mail.value.length == 0 ) {
    alert( "請輸入E-Mail" );
    return false;
  } else {
    i = theForm.e_mail.value.indexOf( "@" );
    j = theForm.e_mail.value.indexOf( ".", i );
    k = theForm.e_mail.value.indexOf( "," );
    kk = theForm.e_mail.value.indexOf( " " );
    jj = theForm.e_mail.value.lastIndexOf( "." ) + 1;
    len = theForm.e_mail.value.length;
    if( ( i <= 0 ) || ( j <= 2 ) || ( k != -1 ) || ( kk != -1 ) || ( len - jj < 2 ) || ( len - jj > 3 ) ) { 
      alert( "E-Mail格式錯誤" );
      return false;
    }
  }

}

//-->
