function check_email1 ( 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_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_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_tw_id(sId){
  var LegalID = "0123456789"
  var fResult=true;
  if(sId.length<10)
    fResult=false;
  else{
    if((sId.charAt(0)=='A') || (sId.charAt(0)=='a')) value=10
    else if((sId.charAt(0)=='B') || (sId.charAt(0)=='b')) value=11
    else if((sId.charAt(0)=='C') || (sId.charAt(0)=='c')) value=12
    else if((sId.charAt(0)=='D') || (sId.charAt(0)=='d')) value=13
    else if((sId.charAt(0)=='E') || (sId.charAt(0)=='e')) value=14
    else if((sId.charAt(0)=='F') || (sId.charAt(0)=='f')) value=15
    else if((sId.charAt(0)=='G') || (sId.charAt(0)=='g')) value=16
    else if((sId.charAt(0)=='H') || (sId.charAt(0)=='h')) value=17
    else if((sId.charAt(0)=='J') || (sId.charAt(0)=='j')) value=18
    else if((sId.charAt(0)=='K') || (sId.charAt(0)=='k')) value=19
    else if((sId.charAt(0)=='L') || (sId.charAt(0)=='l')) value=20
    else if((sId.charAt(0)=='M') || (sId.charAt(0)=='m')) value=21
    else if((sId.charAt(0)=='N') || (sId.charAt(0)=='n')) value=22
    else if((sId.charAt(0)=='P') || (sId.charAt(0)=='p')) value=23
    else if((sId.charAt(0)=='Q') || (sId.charAt(0)=='q')) value=24
    else if((sId.charAt(0)=='R') || (sId.charAt(0)=='r')) value=25
    else if((sId.charAt(0)=='S') || (sId.charAt(0)=='s')) value=26
    else if((sId.charAt(0)=='T') || (sId.charAt(0)=='t')) value=27
    else if((sId.charAt(0)=='U') || (sId.charAt(0)=='u')) value=28
    else if((sId.charAt(0)=='V') || (sId.charAt(0)=='v')) value=29
    else if((sId.charAt(0)=='X') || (sId.charAt(0)=='x')) value=30
    else if((sId.charAt(0)=='Y') || (sId.charAt(0)=='y')) value=31
    else if((sId.charAt(0)=='W') || (sId.charAt(0)=='w')) value=32
    else if((sId.charAt(0)=='Z') || (sId.charAt(0)=='z')) value=33
    else if((sId.charAt(0)=='I') || (sId.charAt(0)=='i')) value=34
    else if((sId.charAt(0)=='O') || (sId.charAt(0)=='o')) value=35
    else fResult = false ;
  }
  if(fResult==true){
    value = Math.floor(value/10) + (value%10)*9 + parseInt(sId.charAt(1))*8 +
            parseInt(sId.charAt(2))*7 + parseInt(sId.charAt(3)) * 6 + parseInt(sId.charAt(4)) * 5 +
            parseInt(sId.charAt(5))*4 + parseInt(sId.charAt(6)) * 3+ parseInt(sId.charAt(7)) * 2+
            parseInt(sId.charAt(8)) + parseInt(sId.charAt(9)) ;
    value = value % 10 ;
    if(value!=0) fResult = false ;
    var i;
    var c;
    for (i = 1; i < sId.length; i++){
      c = sId.charAt(i);
      if (LegalID.indexOf(c) == -1) fResult = false;
    }
  }
  if(fResult == false)
    return "身份證字號錯誤!\n";
  else
    return "";
}