function check_email1 ( email )
{
var len = email.length;
if(len==0)
return "電子信箱不可以空白 !\n";
//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_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_passwd ( pw1, pw2 )
{
if( pw1 == '' ) {
return ("密碼不可以空白 !\n");
}
for( var idx = 0 ; idx <pw1.length ; idx++ ) {
	if( pw1.charAt(idx) == ' ' || pw1.charAt(idx) == '\"' ) {
		return ("密碼不可以含有空白或雙引號 !\n");
	}
	if(!((pw1.charAt(idx) >= "a" && pw1.charAt(idx) <= "z")||(pw1.charAt(idx) >= "0" && pw1.charAt(idx) <= "9"))){
        return "請輸入限用英文，數字組合的密碼!\n";
    }
}	
if( pw1.length < 6 || pw1.length > 12 )
return( "密碼長度只能 6 到 12 個字母 !\n" );
if( pw1 != pw2 )
return("密碼二次輸入不一樣,請重新輸入 !\n");
return "";
}

function check_account ( pw1 )
{
if( pw1 == '' ) {
return ("帳號不可以空白 !\n");
}
for( var idx = 0 ; idx <pw1.length ; idx++ ) {
	if( pw1.charAt(idx) == ' ' || pw1.charAt(idx) == '\"' ) {
		return ("帳號不可以含有空白或雙引號 !\n");
	}
	if(!((pw1.charAt(idx) >= "a" && pw1.charAt(idx) <= "z")||(pw1.charAt(idx) >= "0" && pw1.charAt(idx) <= "9"))){
        return "請輸入限用英文，數字組合的帳號!\n";
    }
}	
if( pw1.length < 5 || pw1.length > 12 )
return( "帳號長度只能 5 到 12 個字母 !\n" );
return "";
}

function check_nan( num ,name )
{
	if( Math.round( new Number(num) ) < 1 ) 
		return name + "不能設定小於1!\n";
	else
		return "";
}

function check_number_YN( number , name )
{
var error = false;
if( number.length <= 0 )
return name + " 不能為空白 !\n";
for( idx = 0 ; idx <number.length ; idx++ ) {
if( !( number.charAt(idx)>= '0' && number.charAt(idx) <= '9' ) ) {
error = true;
break;
}
}

if( error == true )
return name + "只能是數字, 其他的符號都不能使用 !\n";
else
return "";
}

function check_id ( id )
{
var len = id.length;
if(len==0)
return "身份証號不可以空白 !\n";
if(len!=10)
return "身份証號長度有誤 !\n";
//return "您的聯絡信箱選擇備用電子信箱, 所以備用電子信箱不可以空白 !\n";
var local=new Array(36) 
local[10]='A' 
local[11]='B' 
local[12]='C' 
local[13]='D' 
local[14]='E' 
local[15]='F' 
local[16]='G' 
local[17]='H' 
local[18]='J' 
local[19]='K' 
local[20]='L' 
local[21]='M' 
local[22]='N'  
local[23]='P' 
local[24]='Q' 
local[25]='R' 
local[26]='S' 
local[27]='T' 
local[28]='U' 
local[29]='V' 
local[32]='W' 
local[30]='X' 
local[31]='Y' 
local[33]='Z' 
local[34]='I'
local[35]='O'
var fl=id.substring(0,1) 
var haserr=1 
for(i=10;i<=35;i++){	 
if(local[i]!=fl)
continue 
else{ 
haserr=0; 
break 
} 
} 
if(haserr==1) 
return "身分證第一碼查無此英文字母 !\n"; 

var haserr=0 
for(i=1;i<=9;i++){ 
if(parseInt(id.substring(i,i+1))>0 || id.substring(i,i+1)=='0') 
continue 
else{ 
haserr=1 
break} 
} 
if(haserr==1) 
return "輸入的身分證後九碼應為數字 !\n"; 
var se=new Array(10) 
var we=0 
var checkcode=0 
for(i=10;i<=35;i++){ 
if(local[i]==id.substring(0,1)){ 
se[0]=parseInt((i+'0').substring(0,1)) 
se[1]=parseInt((i+'0').substring(1,2)) 
break 
} 
}
for(i=1;i<=9;i++){ 
se[i+1]=parseInt(id.substring(i,i+1)) 
} 
for(i=0;i<=10;i++){ 
if(i==0) 
we=we+se[i]; 
else 
we=we+(se[i]*(10-i)) 
} 
checkcode=((mod(we,10))+'0').substring(0,1) 
if(checkcode!=id.substring(9,10)) 
return "您輸入的身分證檢查碼有誤 !\n";
return "";
function mod(a,b){ 
var r 
r=(a%b) 
if(r > 0){ 
r= b - r }
return r 
} 
}
