
// E-Mail 格式不符 return true
function CheckEmail(str){
		// 檢查是否有填資料
		//alert(str.charCodeAt(0));
		if(str == ""){
			alert("注意!!E-mail信箱不得為空白!!");
			return true;
		}
		// 檢查頭尾是否有 @ = 64 或 . = 46
		if(str.charCodeAt(0) == 64 || str.charCodeAt(str.length-1) == 64 || str.charCodeAt(0) == 46 || str.charCodeAt(str.length-1) == 46){
				alert("E-Mail輸入錯誤");
				return true;
		}
		// 檢查是否 @
		i=0;
		while(str.charCodeAt(i) != 64){
			if(i < str.length-1){
				i++;
			} else{
				break;
			}
		}
		if(i==str.length-1){
			alert("E-Mail輸入錯誤!");
			return true;	
		}
			
		// 檢查是否 .
		i=0;
		while(str.charCodeAt(i) != 46){
			if(i < str.length-1){
				i++;
			} else{
				break;
			}
		}
		if(i==str.length-1){
			alert("E-Mail輸入錯誤!");
			return true;	
		}
		
		//alert("E-Mail輸入成功");
		return false;
		
	}

// 檢查身份證號碼
function idCheck(txt)
{   
   var fResult=true;
   var value = 0;
   var sId=txt;
   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 ;
     //alert('Value='+value) ;
   }
   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 ;
    }
    return fResult ;
}

//檢查是否為數字
function isANumber(txt, message)
{
	answer = true;
	if (!parseFloat(txt)) {
		//the first digit wasn't numeric
		answer = false;
		//alert("Please enter a numeric value for the " + message + " field.");
	} else {
		//the first digit was numeric, so check the rest
		for (var i=0; i<txt.length; i++) {
			if ((txt.charAt(i) != "0") && (!parseFloat(txt.charAt(i)))) {
				answer = false;
				//alert("Please enter a numeric value for the " + message + " field.");
				break;
			}
		}
	}
	return answer;
}