<!--
function check_acpw (acpw,name)
{
    var error = false;
    if (acpw.length <=0)
        return name + "不可以空白 !\n";
    if (acpw.length >12)
        return name + "不可以超過12個字 !\n";               
    for( idx = 0 ; idx < acpw.length ; idx++ ) {
    	if( ! ( (acpw.charAt(idx) >= '0' && acpw.charAt(idx) <= '9' )||(acpw.charAt(idx) >= 'a' && acpw.charAt(idx) <= 'z' )||(acpw.charAt(idx) >= 'A' && acpw.charAt(idx) <= 'Z' ))) {
    	    error = true;
    	    break;
    	}
    }
    if( error == true )
        return  name + "只能接受英文及數字!\n";
    return "";
}
function check_telephonenumber ( number )
{
    var error = false;
    if( number.length <= 0 )
        return "";
    for( idx = 0 ; idx < number.length ; idx++ ) {
        if( !( ( number.charAt(idx) >= '0' && number.charAt(idx) <= '9' ) || ( number.charAt(idx) == '-' ) ) ) {
            error = true;
            break;
        }
    }
    if( error == true )
        return "您的通訊電話只能是數字及'-'等符號, 其他的符號都不能使用 !\n";
    return "";
}    
function check_email ( email )
{
   var len = email.length;
   if( len <= 0 )
       return "您的電子郵件還沒填呢 !\n";
   for(var i=0;i<len;i++)
   {  var c= email.charAt(i);
      if(!((c>="A"&&c<="Z")||(c>="a"&&c<="z")||(c>="0"&&c<="9")||(c=="-")||(c=="_")||(c==".")||(c=="@")))
         return "您的電子郵件地址不合法 !\n";
   }
   if((email.indexOf("@")==-1)||(email.indexOf("@")==0)||(email.indexOf("@")==(len-1)))
      return "您的電子郵件地址不合法 !\n";
   if((email.indexOf("@")!=-1)&&(email.substring(email.indexOf("@")+1,len).indexOf("@")!=-1))
      return "您的電子郵件地址不合法 !\n";
   if((email.indexOf(".")==-1)||(email.indexOf(".")==0)||(email.lastIndexOf(".")==(len-1)))
      return "您的電子郵件地址不完全 !\n";
   return "";
}
function check_null ( column, name )
{
    if( column.length == 0 )
        return name + "不可以空白 !\n";
    return "";
}
function check_pwd ( column1, column2 )
{
    if( column1.value != column2.value )
        return "兩次密碼不相同 !\n";
    return "";
}
function check_select ( select, name )
{
    if( select.options[0].selected == true )
        return name + "必須選擇 !\n";
    return "";
}
function check_radio ( radio, name )
{
    var error = true;
    for( i=0; i < radio.length; i++ )
        if( radio[i].checked == true ) {
            error = false;
            break;
        }
    if( error == true )
        return name + "必須選擇 !\n";
    return "";
}
function check_birthday_year( year )
{
    var error = false;
    if( year.length != 4 )
        return ("您的生日年份必須是四個數字, 例如 1980 年 !\n");
    for( idx = 0 ; idx < year.length ; idx++ ) {
        if( !( year.charAt(idx) >= '0' && year.charAt(idx) <= '9' ) ) {
            error = true;
            break;
        }
    }
    if( error == true )
        return ("您的生日年份必須是四個數字, 例如 1980 年 !\n");
    return "";
}
function check_num(num,name)
{
    var error = false;  
    for( idx = 0 ; idx < num.length ; idx++ ) {
        if( !( num.charAt(idx) >= '0' && num.charAt(idx) <= '9' ) ) {
            error = true;
            break;
        }
    }
    if( error == true )
        return name + "請填寫正確 !\n";
    return "";    
}
function checkbasic()
{
var thisForm = document.form1;

var alertStr= check_acpw (thisForm.account.value,"帳號");
alertStr += check_acpw (thisForm.pwd.value,"密碼");
alertStr += check_pwd( thisForm.pwd,thisForm.repwd );
alertStr += check_null( thisForm.name.value, "姓名" );
alertStr += check_radio( thisForm.sex, "性別" );
alertStr += check_select( thisForm.birthY, "生日年份" );
alertStr += check_select( thisForm.birthM, "生日月份" );
alertStr += check_select( thisForm.birthD, "生日日期" );
alertStr += check_telephonenumber( thisForm.tel.value );
alertStr += check_email( thisForm.email.value);
alertStr += check_null( thisForm.zipcode.value,"郵遞區號");
alertStr += check_num( thisForm.zipcode.value,"郵遞區號");
alertStr += check_null( thisForm.address.value,"地址");
alertStr += check_radio( thisForm.opt3, "是否買過千華參考書" );
if( alertStr != '' ) {
    alert( alertStr );
    return false;
}
return true;
}
function checkmod()
{
var thisForm = document.form1;
var alertStr= check_null( thisForm.name.value, "姓名" );
alertStr += check_radio( thisForm.sex, "性別" );
alertStr += check_birthday_year( thisForm.birthY.value );
alertStr += check_num( thisForm.birthM.value, "生日月份" );
alertStr += check_num( thisForm.birthD.value, "生日日期" );
alertStr += check_telephonenumber( thisForm.tel.value );
alertStr += check_email( thisForm.email.value);
alertStr += check_null( thisForm.zipcode.value,"郵遞區號");
alertStr += check_num( thisForm.zipcode.value,"郵遞區號");
alertStr += check_null( thisForm.address.value,"地址");
alertStr += check_radio( thisForm.opt3, "是否買過千華參考書" );
if( alertStr != '' ) {
    alert( alertStr );
    return false;
}
return true;
}
function checkforget()
{
var thisForm = document.form1;
var alertStr= check_null( thisForm.account.value, "帳號" );
alertStr += check_null( thisForm.name.value, "姓名" );
alertStr += check_email( thisForm.email.value);
if( alertStr != '' ) {
    alert( alertStr );
    return false;
}
return true;
}
function checkhint()
{
var thisForm = document.form1;
var alertStr= check_null( thisForm.hintans.value, "提示語答案" );
if( alertStr != '' ) {
    alert( alertStr );
    return false;
}
return true;
}
function checkreset()
{
var thisForm = document.form1;
var alertStr= check_null (thisForm.pwd.value,"密碼");
alertStr += check_pwd( thisForm.pwd,thisForm.pwd2 );
if( alertStr != '' ) {
    alert( alertStr );
    return false;
}
return true;
}
function checkcpwd()
{
var thisForm = document.form1;
var alertStr= check_null (thisForm.opwd.value,"舊密碼");
alertStr += check_null (thisForm.pwd.value,"密碼");
alertStr += check_pwd( thisForm.pwd,thisForm.repwd );
if( alertStr != '' ) {
    alert( alertStr );
    return false;
}
return true;
}
//-->
