//v1.0
function chkNoChar(txt,targetName){
	for(i=0;i<txt.length;i++){
	c = txt.charAt(i);
	if("!@#$%^/\"\'&*()+|".indexOf(c,0)>0){	alert("您在「"+targetName+"」輸入了不被接受的符號！");	return false;	}		
	}
}
function chkEmail(txt){
	data = txt.match(/^\S+@\S+\.\S+$/)
	if (!data || !txt) return false;
	return true;
}
function jsLtrim(txt){
	while (txt.indexOf(" ") == 0 ){	txt = txt.replace(" ","");	}
	return txt;
}

function jsRtrim(txt){
	while (txt.charAt(txt.length-1) == " " ){	txt = txt.substr(0,txt.length-1);	}
	return txt;
}
function chkNum(getkeyCode){
	c = getkeyCode;
	if((c>=35&&c<=45)||(c>=48&&c<=57)||(c>=96&&c<=105)||c==8||c==9||c==13||c==46||c==229) return true; return false;
}


function form_check(who){
//check name
	mytxt = document.form1.name.value;
	mytxt = jsLtrim(mytxt);mytxt = jsRtrim(mytxt);
	if(mytxt.length < 2){
	alert("「姓名」不得少於 2 個字元");return false;
	}

//check year
	mytxt = document.form1.year.value;
	mytxt = jsLtrim(mytxt);mytxt = jsRtrim(mytxt);
	if(mytxt.length < 2){
	//alert("請在「出生年」輸入您的出生年!");return false;
	}
//check tel
	mytxt = document.form1.tel.value;
	mytxt = jsLtrim(mytxt);mytxt = jsRtrim(mytxt);
	if(mytxt.length < 8){
	alert("您輸入的「電話號碼」過短...請再確認!!");return false;
	}
//check todate	
    var totalcheck = 0;
    for(i=0;i<=5;i++){
      if(who["todate["+i+"]"].checked == true){
        totalcheck++;
      }
    }
    if(totalcheck == 0){
      alert('請選擇「希望預約之時間」，點選星期一~星期六!');
      return false;
    }
//check toTime	
    var totalcheck2 = 0;
    for(i=0;i<=2;i++){
      if(who["toTime["+i+"]"].checked == true){
        totalcheck2++;
      }
    }
    if(totalcheck2 == 0){
      alert('請選擇「希望預約之時段」，點選早診、午診或晚診!');
      return false;
    }
//check q8
    var totalcheck3 = 0;
    for(i=0;i<=3;i++){
      if(who["q8["+i+"]"].checked == true){
        totalcheck3++;
      }
    }
    if(totalcheck3 == 0){
      alert("請選擇「曾有下顎關節異常現象」尚未勾選！")
      return false;
    }
//check q9
    var totalcheck4 = 0;
    for(i=0;i<=4;i++){
      if(who["q9["+i+"]"].checked == true){
        totalcheck4++;
      }
    }
    if(totalcheck4 == 0){
      alert("請選擇「目前假牙有異常狀況」尚未勾選！")
      return false;
    }	
//check q10
    var totalcheck5 = 0;
    for(i=0;i<=5;i++){
      if(who["q10["+i+"]"].checked == true){
        totalcheck5++;
      }
    }
    if(totalcheck5 == 0){
      alert("請選擇「曾有不好的診療經驗」尚未勾選！")
      return false;
    }
//check t1
    var totalcheck6 = 0;
    for(i=0;i<=9;i++){
      if(who["t1["+i+"]"].checked == true){
        totalcheck6++;
      }
    }
    if(totalcheck6 == 0){
      alert("請選擇「此次看診希望醫師為解決什麼問題」尚未勾選！")
      return false;
    }
	
}