function check(){
	if(!trim(form.ID.value)){alert('．請輸入帳號');form.ID.focus();return false;}
	if(!ischar(form.ID.value)){form.ID.select();return false;}
	if(!checkBytes(form.ID.value)){form.ID.select();return false;}
	if(trim(form.ID.value).length < 6){alert('．帳號至少6個字元');form.ID.focus();return false;}
	if(!trim(form.PW.value)){alert('．請輸入密碼');form.PW.focus();return false;}
	if(!ischar(form.PW.value)){form.PW.select();return false;}
	if(!checkBytes(form.PW.value)){form.PW.select();return false;}
	if(!trim(form.CPW.value)){alert('．請輸入密碼確認');form.CPW.focus();return false;}
	if(!ischar(form.CPW.value)){form.CPW.select();return false;}
	if(!checkBytes(form.CPW.value)){form.CPW.select();return false;}
	if(trim(form.PW.value).length < 5){alert('．密碼至少5個字元');form.PW.focus();return false;}
	if(trim(form.PW.value) != trim(form.CPW.value)){alert('．密碼確認錯誤');form.CPW.focus();return false;}
	if(!trim(form.name.value)){alert('．請輸入姓名');form.name.focus();return false;}
	if(!trim(form.biry.value)){alert('．請輸入生日(年)');form.biry.focus();return false;}
	if(isNaN(Math.abs(form.biry.value))){alert('生日(年)必需是數字');form.biry.focus();return false;}
	if(!trim(form.birm.value)){alert('．請輸入生日(月)');form.birm.focus();return false;}
	if(isNaN(Math.abs(form.birm.value))){alert('生日(月)必需是數字');form.birm.focus();return false;}
	if(!trim(form.bird.value)){alert('．請輸入生日(日)');form.bird.focus();return false;}
	if(isNaN(Math.abs(form.bird.value))){alert('生日(日)必需是數字');form.bird.focus();return false;}

	if(trim(form.petbiry.value)){
		if(isNaN(Math.abs(form.petbiry.value))){alert('寵物生日(年)必需是數字');form.petbiry.focus();return false;}
	}
	if(trim(form.petbirm.value)){
		if(isNaN(Math.abs(form.petbirm.value))){alert('寵物生日(月)必需是數字');form.petbirm.focus();return false;}
	}
	if(trim(form.petbird.value)){
		if(isNaN(Math.abs(form.petbird.value))){alert('寵物生日(日)必需是數字');form.petbird.focus();return false;}
	}
	if(!form.sex[0].checked && !form.sex[1].checked){alert('．請選擇性別');form.sex[0].focus();return false;}
	if(!trim(form.email.value)){alert('．請輸入E-Mail');form.email.focus();return false;}
	if(form.email.value.indexOf("@")=="-1" || form.email.value.indexOf(".")=="-1"){alert("．不正確的電子信箱");form.email.select();return false;}	
	if(!trim(form.Code.value)){alert('．請輸入驗證碼');form.Code.focus();return false;}
	if(!ischar(form.Code.value)){form.Code.select();return false;}
	form.btnSubmit.disabled = true;
        form.submit();
}
function trim(instr){
        return instr.replace(/^[\s]*/gi,'').replace(/[\s]*$/gi,'');
}
function isNumeric(Key){
       if((Key < 48 || Key > 57)){
               window.event.keyCode = 0;
       } 
}
function ischar(s){
        var errorChar;
        var badChar = "><[]{}?/\+=|'~!#$%^&()`"; 

        errorChar = isCharsInBagEx(s,badChar);
        if (errorChar != ''){
                alert('．請勿輸入特殊字元('+ badChar +')');
                return false;
        }
        return true;
}
function isCharsInBagEx(s,bag){ 
        var i,c;
        for (i = 0; i < s.length; i++){ 
                c = s.charAt(i);
                if (bag.indexOf(c) > -1){
                return c
                }
        }
        return '';
}
function checkBytes(obj) { 
   	var hasChinese = false;
   	var n = obj.length;
  	for(var i=0;i<n;i++){
    		var str = encodeURI(obj.charAt(i));
       		if(str.length == 9){
        		hasChinese = true;
        		break;
        	}
   	}
   	if(hasChinese){
   		alert("．請勿輸入中文字");
   		return false;
   		return true;
   	}else{
   		return true;
   	}
}
function checkKey(key){
        if((key < 48 || key > 57) && (key < 65 || key > 90) && (key < 97 || key > 122) && (key != 95)){
                window.event.keyCode = 0;
        } 
}
function isInteger(e){
	var key = window.event ? e.keyCode : e.which;
	var keychar = String.fromCharCode(key);

        if(key < 48 || key > 57){
		return false;
	}
}