function to_obj(res) { var arr = res.split("|"); return {result:arr[0],say:arr[1],url:arr[2]} } function a() { res = cacheIframe.document.body.innerText; var arr = res.split("|"); result= arr[0]; say= arr[1]; url= arr[2]; if(result=="1") { alert(say); if(url!="") { location.href=url; } } else if(result=="0") { alert(say); } } function g(v) { return document.getElementById(v); } //定义serializeObject方法,序列化表单 $.fn.serializeObject = function () { var o = {}; var a = this.serializeArray(); $.each(a, function () { if (o[this.name]) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; } function GetAgeByBrithday(birthdayYear,birthdayMonth,birthdayDay) { var age=-1; var today=new Date(); var todayYear=today.getFullYear(); var todayMonth=today.getMonth()+1; var todayDay=today.getDate(); if( birthdayYear=="" || birthdayMonth=="" || birthdayDay=="" ) { return -1; } if(todayYear-birthdayYear<0) { return -1; } console.log("todayYear:"+todayYear*1); console.log("todayMonth:"+todayMonth*1);; console.log("todayDay:"+todayDay*1); console.log("birthdayYear:"+birthdayYear); console.log("birthdayMonth:"+birthdayMonth); console.log("birthdayDay:"+birthdayDay); month_diff = todayMonth*1-birthdayMonth*1; console.log("month_diff:"+month_diff); if( month_diff <0) { age = (todayYear*1-birthdayYear*1)-1; console.log("Month<0:"+age); return age; } if( month_diff >0) { age = (todayYear*1-birthdayYear*1); console.log("Month>0:"+age); return age; } //month_diff ==0 的情況 day_diff = todayDay*1 - birthdayDay*1; console.log("day_diff:"+day_diff); if(day_diff>=0) { age = (todayYear*1-birthdayYear*1); console.log("Day>=0:"+age); return age; } else { age = (todayYear*1-birthdayYear*1)-1; console.log("Day<0:"+age); return age; } return age*1; } function under11YearOld(birthdayYear,birthdayMonth,birthdayDay) { var age = GetAgeByBrithday(birthdayYear,birthdayMonth,birthdayDay); if(age<=10) { return true; } return false; } function passport_blur(temp_obj) { temp_id = temp_obj.id; // alert("temp_id:"+temp_id); temp_value = temp_obj.value; // alert("temp_value:"+temp_value); new_id = temp_id.substr(0,temp_id.length-5); // alert("new_id:"+new_id); // alert(temp_value); if(temp_value=="") { document.getElementById(new_id).value = ""; temp_obj.value = ""; return ; } if(temp_value=="*****") { document.getElementById(new_id).value = ""; // temp_obj.value = ""; return ; } if(temp_value!="*****" ) { document.getElementById(new_id).value = temp_value; temp_obj.value = "*****"; } } function passport_focus(temp_obj) { temp_id = temp_obj.id; // alert("temp_id:"+temp_id); temp_value = temp_obj.value; // alert("temp_value:"+temp_value); new_id = temp_id.substr(0,temp_id.length-5); // alert("new_id:"+new_id); temp_obj.value = document.getElementById(new_id).value; } function radioValue(elementName) { val=getSelectValue(elementName,"radio"); if(val==false) { return ""; } else { return val; } } function selectValue(elementName) { val=getSelectValue(elementName,"checkbox"); if(val==false) { return ""; } else { return val; } } //中港澳 的 ID function is_shuifeng_address_id(v) { if(v=="1" || v=="25" || v=="27") { return true; } return false; } // ielts 額外成績單, 中港澳 才 出現順豐 可以選 function postage_change(obj) { var select_value = obj.value; out_post_change_do(select_value); } function out_post_change_do(select_value) { var result = is_shuifeng_address_id(select_value); if(result==true) { document.getElementById("shuifeng_div").style.display="block"; } else { document.getElementById("shuifeng_div").style.display="none"; //清除选择 // document.getElementById("shuifeng_button").checked=false; $("#shuifeng_div input:radio").attr("checked",false); } } //手机 function check_tel(value) { //   var reg = new RegExp("^/([0-9A-Z\+\-\.]{7})$"); //正则表达式 var reg =/^\/([0-9A-Za-z\+\-\.]{7})$/; if(reg.test(value)) { return true; } else { return false; } } //自然人 function check_nature(value) {    var reg = /^[A-Za-z]{2}[0-9]{14}$/; if(reg.test(value)) { return true; } else { return false; } } //愛心碼 //「愛心碼」基本檢核條件:條碼長度3~7碼,數字為0~9,故第 1 碼可能是「0」。 function check_love(value) {  var reg =/^[0-9]{3,7}$/; if(reg.test(value)) { return true; } else { return false; } } function receipt_check_do() { return receipt_check(); } function receipt_check() { // alert("ddddddddddddd11111111111111111111111111111111111dddddddd"); var v_receipt_type = document.getElementById("receipt_type").value; //getSelectValue("receipt_type","radio"); // alert(v_receipt_type); if(v_receipt_type=="") { alert("请选择发票类型!"); document.getElementById("receipt_type").focus(); return false; } //個人電子發票 if(v_receipt_type=="1") { var v_elec_receipt_type = getSelectValue("elec_receipt_type","radio"); if(v_elec_receipt_type==false) { alert("请选择个人电子发票的类型!"); return false; } if(v_elec_receipt_type=="elec") { if(document.getElementById("tele_receipt_code").value=="") { alert("请输入手机条码载具条码!"); document.getElementById("tele_receipt_code").focus(); return false; } var value = document.getElementById("tele_receipt_code").value; var result = check_tel(value); if( result ==false ) { //alert("請輸入正確的「手機條碼」,檢核條件: /+7位Code39"); alert("请输入正确的「手机条码」"); document.getElementById("tele_receipt_code").focus(); return false; } if(document.getElementById("tele_receipt_code2").value=="") { alert("请再次输入手机条码载具条码!"); document.getElementById("tele_receipt_code2").focus(); return false; } if(document.getElementById("tele_receipt_code").value != document.getElementById("tele_receipt_code2").value) { alert("两次输入手机条码载具条码不一样!"); document.getElementById("tele_receipt_code").focus(); return false; } } if(v_elec_receipt_type=="nature") { if(document.getElementById("nature_receipt_code").value=="") { alert("请输入自然人凭证载具!"); document.getElementById("nature_receipt_code").focus(); return false; } value = document.getElementById("nature_receipt_code").value; var result = check_nature(value) if( result == false ) { //alert("請輸入正確的「自然人憑證條碼」,檢核條件: 2 位大寫字母+14位數字。"); alert("请输入正确的「自然人凭证条码」"); document.getElementById("nature_receipt_code").focus(); return false; } if(document.getElementById("nature_receipt_code2").value=="") { alert("请再次输入自然人凭证载具!"); document.getElementById("nature_receipt_code2").focus(); return false; } if(document.getElementById("nature_receipt_code").value!=document.getElementById("nature_receipt_code2").value) { alert("两次输入自然人凭证载具不一样!"); document.getElementById("nature_receipt_code").focus(); return false; } } } //捐贈 if(v_receipt_type =="2" ) { var v_love_fund = getSelectValue("love_fund","radio"); if(v_love_fund==false) { alert("请选择捐赠的爱心机构!"); return false; } if(v_love_fund =="other") { if(document.getElementById("other_love_fund").value == "" ) { alert("请输入爱心码!"); document.getElementById("other_love_fund").focus(); return false; } var value = document.getElementById("other_love_fund").value; var result = check_love(value); if( result == false ) { //alert("請輸入正確的「愛心碼」,檢核條件:條碼長度3~7碼,數字為0~9!"); alert("请输入正确的「爱心码」"); document.getElementById("other_love_fund").focus(); return false; } } } //三聯式紙本 if(v_receipt_type =="4" ) { if(document.getElementById("header1").value=="") { alert("请输入抬头!"); document.getElementById("header1").focus(); return false; } if(document.getElementById("header2").value=="") { alert("请输入统编!"); document.getElementById("header2").focus(); return false; } oHeader2 =document.getElementById("header2"); oHeader_name =document.getElementById("header1"); var result = /.*[\u4e00-\u9fa5]+.*$/.test(oHeader_name.value) ; if(result==false) //判断中文 { alert("“发票抬头”请输入中文!") oHeader_name.focus(); return false; } if(oHeader_name.value.length<=3) { alert("请输入大于三个中文字的“发票抬头”!") oHeader_name.focus(); return false; } obj1 =document.getElementById("header2"); if(!isInt(obj1.value)) { alert('"统编"栏位只接受8位数的数字,请重新输入!'); obj1.focus(); return false; } if(obj1.value.length!="8") { alert('"统编"栏位只接受8位数的数字,请重新输入!'); obj1.focus(); return false; } } return true; } function receipt_tele_check_manager() { var value = document.getElementById("tele_receipt_code").value; if(value!="") { var result = check_tel(value); if( result ==false ) { //alert("請輸入正確的「手機條碼」,檢核條件: /+7位Code39"); alert("请输入正确的「手机条码」"); document.getElementById("tele_receipt_code").focus(); return false; } } return true; } function receipt_nature_check_manager() { value = document.getElementById("nature_receipt_code").value; if(value!="") { var result = check_nature(value) if( result == false ) { //alert("請輸入正確的「自然人憑證條碼」,檢核條件: 2 位大寫字母+14位數字。"); alert("请输入正确的「自然人凭证条码」"); document.getElementById("nature_receipt_code").focus(); return false; } } return true; } function receipt_love_check_manager() { value = document.getElementById("love_fund").value; if(value!="") { var result = check_love(value) if( result == false ) { alert("請輸入正確的「愛心碼」,檢核條件:條碼長度3~7碼,數字為0~9!"); document.getElementById("love_fund").focus(); return false; } } return true; } function header1_header2_check_manager() { oHeader_name =document.getElementById("header1"); if(oHeader_name.value!="") { var result = /.*[\u4e00-\u9fa5]+.*$/.test(oHeader_name.value) ; if(result==false) //判断中文 { alert("“发票抬头”请输入中文!") oHeader_name.focus(); return false; } if(oHeader_name.value.length<=3) { alert("请输入大于三个中文字的“发票抬头”!") oHeader_name.focus(); return false; } } oHeader2 =document.getElementById("header2"); if(oHeader2.value!="") { if(!isInt(oHeader2.value)) { alert('"统编"栏位只接受8位数的数字,请重新输入!'); oHeader2.focus(); return false; } if(oHeader2.value.length!="8") { alert('"统编"栏位只接受8位数的数字,请重新输入!'); oHeader2.focus(); return false; } if( !taiwanIdValidator.isGuiNumberValid(oHeader2.value, true) ) { alert("统编检查有误,请再check!"); oHeader2.focus(); return false; } } return true; } function header1_header2_check() { if(document.getElementById("header1").value=="") { alert("请输入抬头!"); document.getElementById("header1").focus(); return false; } oHeader2 =document.getElementById("header2"); if(oHeader2.value=="") { alert("请输入统编!"); oHeader2.focus(); return false; } if( !taiwanIdValidator.isGuiNumberValid(oHeader2.value, true) ) { alert("统编检查有误,请再check!"); oHeader2.focus(); return false; } oHeader_name =document.getElementById("header1"); var result = /.*[\u4e00-\u9fa5]+.*$/.test(oHeader_name.value) ; if(result==false) //判断中文 { alert("“发票抬头”请输入中文!") oHeader_name.focus(); return false; } if(oHeader_name.value.length<=3) { alert("请输入大于三个中文字的“发票抬头”!") oHeader_name.focus(); return false; } obj1 =document.getElementById("header2"); if(!isInt(obj1.value)) { alert('"统编"栏位只接受8位数的数字,请重新输入!'); obj1.focus(); return false; } if(obj1.value.length!="8") { alert('"统编"栏位只接受8位数的数字,请重新输入!'); obj1.focus(); return false; } return true; } function send_turn_mail(no) { ajax_post2(ajax_url+"ajax_function/send_turn_order_ajax.php?no="+no,{},function(data) { if(data=="1") { alert("发送成功!"); } else { x2= data.substring(1); alert(x2); return false; } }); } function send_turn_mail2() { v_order_no = document.all.modify_date_new_order_no.value; JS.get("controller.php?a=send_turn_order_ajax2&order_no="+v_order_no+"&checksum="+document.getElementById('checksum').value, {}, function(data) { obj = to_obj(data); if(obj.result=="1") { alert("发送成功!"); document.getElementById("turn_button_div").innerHTML = ""; } else { alert(obj.say); return false; } } ); } function update_modify_input() { if(document.getElementById("email").value!=old_email) { document.getElementById("modify_email").value="1"; } if(document.getElementById("telephone2").value!=old_telephone) { document.getElementById("modify_telephone").value="1"; } if(document.getElementById("mobile").value!=old_mobile) { document.getElementById("modify_mobile").value="1"; } if(document.getElementById("live_address").value!=old_address) { document.getElementById("modify_address").value="1"; } } function update_modify_input2() { if(document.getElementById("telephone2").value!=old_telephone) { document.getElementById("modify_telephone").value="1"; } if(document.getElementById("mobile").value!=old_mobile) { document.getElementById("modify_mobile").value="1"; } if(document.getElementById("live_address").value!=old_address) { document.getElementById("modify_address").value="1"; } } function update_modify_input3() { if(document.getElementById("telephone2").value!=old_telephone) { document.getElementById("modify_telephone").value="1"; } if(document.getElementById("mobile").value!=old_mobile) { document.getElementById("modify_mobile").value="1"; } } function update_modify_input_modify_type() { if(document.getElementById("telephone2").value!=old_telephone) { document.getElementById("modify_telephone").value="1"; } if(document.getElementById("mobile").value!=old_mobile) { document.getElementById("modify_mobile").value="1"; } if(document.getElementById("live_address").value!=old_address) { document.getElementById("modify_address").value="1"; } } function check_telephone(input_name) { obj1 =document.getElementById(input_name+"1"); obj2 =document.getElementById(input_name+"2"); if(obj1.value=="") { alert('"电话"栏位输入区号,请重新输入!'); obj1.focus(); return false; } if( obj2.value=="") { alert('"电话"栏位输入电话号码,请重新输入!'); obj2.focus(); return false; } if(obj2.value != old_telephone ) { if(isHaveStar(obj2.value)==true) { alert('"电话"栏位输入不正确,请不要带有*号!'); obj2.focus(); return false; } } } function check_email(input_name) { obj1 =document.getElementById(input_name); if(obj1.value=="") { alert('"E-mail"是必填栏位,请输入!'); obj1.focus(); return false; } if(obj1.value != old_email ) { if(!isEmail( obj1.value )) { alert('"E-mail"栏位输入不正确,请重新输入!'); obj1.focus(); return false; } } return true; } function check_passport() { // var v_type = getSelectValue("passport_type","radio"); var v_type = "passport"; var v_passport =document.getElementById("passport").value; var v_country =document.getElementById("origin_country").value; // 國籍 中國 passport (T or t) +8個數字 if(v_type=="passport" && v_country=="43" ) { r = is_china_national_id( v_passport ); if( r==true) { alert("请填写正确的护照号码,你所填写的是 大陆居民往来台湾通行证,无法报名雅思考试"); document.getElementById("passport").focus(); return false; } } //台湾 人 身份证不可以 //身分證字號一共有十碼,包括起首一個大寫的英文字母與接續的九個阿拉伯數字。 //第1個字 英文( 小寫,大寫 都可能) + 9個數字 //alert("請填寫正確的護照號碼,你所填寫的是 身份證,無法報名雅思考試"); // alert("passport:"); // alert(v_type); // alert("国家:"); // alert(v_country); if( v_type=="passport" && v_country=="1" ) { // alert(v_passport); // var reg1 =/^([\w]{1})([0-9]{9})$/; r = is_national_id( v_passport ); if(r==true) { alert("请填写正确的护照号码"); document.getElementById("passport").focus(); return false; } } return true; } function check_passport2(v_passport,focus_id) { var v_type = "passport"; var v_country =document.getElementById("origin_country").value; // 國籍 中國 passport (T or t) +8個數字 if(v_type=="passport" && v_country=="43" ) { r = is_china_national_id( v_passport ); if( r==true) { alert("请填写正确的护照号码,你所填写的是 大陆居民往来台湾通行证,无法报名雅思考试"); document.getElementById(focus_id).focus(); return false; } } //台湾 人 身份证不可以 //身分證字號一共有十碼,包括起首一個大寫的英文字母與接續的九個阿拉伯數字。 //第1個字 英文( 小寫,大寫 都可能) + 9個數字 //alert("請填寫正確的護照號碼,你所填寫的是 身份證,無法報名雅思考試"); // alert("passport:"); // alert(v_type); // alert("国家:"); // alert(v_country); if( v_type=="passport" && v_country=="1" ) { // alert(v_passport); // var reg1 =/^([\w]{1})([0-9]{9})$/; r = is_national_id( v_passport ); if(r==true) { alert("请填写正确的护照号码"); document.getElementById(focus_id).focus(); return false; } } return true; } //是否 不是 中国护照 /* function is_china_national_id(v_passport) { r = false; var reg1 =/^(EA|DE|SE|PE)[0-9]{7}$/; r1 = reg1.test( v_passport ); var reg1 =/^(E|G|D|S|P)[0-9]{8}$/; r2 = reg1.test( v_passport ); if(r1 || r2 ) { r = true; } return !r; } */ function is_china_national_id(v_passport) { var pre = v_passport.substr(0,1); var tail_number = v_passport.substr(1); if( pre=="T" || pre=="t" || pre=="L" || pre=="l") { if(isNum(tail_number)==true) { if(tail_number.length==8) { return true; } } } return false; } function is_national_id(v_passport) { // var reg1 =/^([\w]{1})([0-9]{9})$/; var reg1 =/^([0-9]{9})$/; r = reg1.test( v_passport ); return !r; } function goUrl(url) { location.href=url; } function getE(name) { return document.getElementById(name).value; } function focusF(name) { return document.getElementById(name).focus(); } function openerwin(url) { if (opener.closed){ NewWin = window.open("","MWindow","toolbar=yes,location=yes,directories=yes,status=yes,resizable=1,scrollbars=1"); NewWin.location.href=url ; } else opener.location.href=url; window.close(); } function newwin(url) { NewWin = window.open("","MWindow","toolbar=yes,location=yes,directories=yes,status=yes,resizable=1,scrollbars=1"); NewWin.location=url ; window.close(); } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i width1) { break; } else { result = string.substr(0,i+1); i++; } } if(result != string) { result += "..."; } return result; } /*是否已經選擇 * */ function isSelect(selectObj) { for(i=0;i12) { return false; } if(day1>31) { return false; } return true; } else { return false; } return false; } function isEmail( email ) { var reg1 =/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; return reg1.test( email ); } function trim( text ) { if (typeof(text) == "string") { return text.replace(/^\s*|\s*$/g, ""); } else { return text; } } function isEmpty( val ) { switch (typeof(val)) { case 'string': return trim(val).length == 0 ? true : false; break; case 'number': return val == 0; break; case 'object': return val == null; break; case 'array': return val.length == 0; break; default: return true; } } function isNotEmpty( val ) { return !isEmpty(val); } function isBlank(elementName) { obj=document.getElementById(elementName); // obj=eval('document.register.'+elementName); if(obj==undefined) { return false; } type = obj.type; if(type=='text' || type=='textarea') { val = obj.value; return trim(val).length == "" ? true : false; } else if(type=='select-one') { val = obj.options[obj.options.selectedIndex].value; return trim(val).length == "" ? true : false; } else if(type=='checkbox') { val=getCheckSelectObject(elementName,"checkbox"); val=val.toString(); return trim(val).length == "" ? true : false; } else if(type=='radio') { val=getSelectValue(elementName,"radio"); if(val==false) { return true; } else { return false; } } else { val = obj.value; return trim(val).length == "" ? true : false; } return false; } function radioValue(elementName) { val=getSelectValue(elementName,"radio"); if(val==false) { return ""; } else { return val; } } function isBlank2(elementName) { obj=document.getElementById(elementName); val=getSelectValue(elementName,"radio"); if(val==false) { return true; } else { return false; } } function isBlank3(elementName) { obj=document.getElementById(elementName); val=getSelectValue(elementName,"checkbox"); if(val==false) { return true; } else { return false; } } function isEnglish(val){ if( /^[a-zA-Z ]{1,}$/.test(val)){ return true; } else { return false; } } function isEnglish1(val){ if( /^[a-zA-Z\- ']{1,}$/.test(val)){ return true; } else { return false; } } function isEnglish_and_digit(val){ if( /^[a-zA-Z0-9]{1,}$/.test(val)){ return true; } else { return false; } } function UrlEncode(str){ var ret=""; var strSpecial="!\"#$%&'()*+,/:;<=>?[]^`{|}~%"; for(var i=0;i 0x7f){ ret+="%"+c.slice(0,2)+"%"+c.slice(-2); }else{ if(chr==" ") ret+="+"; else if(strSpecial.indexOf(chr)!=-1) ret+="%"+c.toString(16); else ret+=chr; } } return ret; } function UrlDecode(str){ var ret=""; for(var i=0;i0x7f){ ret+=asc2str(parseInt("0x"+asc+str.substring(i+4,i+6))); i+=5; }else{ ret+=asc2str(parseInt("0x"+asc)); i+=2; } }else{ ret+= chr; } } return ret; } function countryDel(field) { document.getElementById(field+'_name').value=''; document.getElementById(field+'_code').value=''; document.getElementById(field).value=''; } function checkTeamAddress(in_address3Error,in_addressError,out_address1Error,in_shipmentError,out_shipmentError,a1Error,a2Error) { val=getValueSelectObject("allAddress[]","hidden"); for(i=0;it2) { return date1; } else { return date2; } } function fclick_upload(event,objName) { bw = navigator.appName; if(bw=="Netscape") { file_width = 77; y = event.target.offsetTop-7; b_l =event.target.offsetLeft; b_r =event.target.offsetLeft+event.target.width; x_middle = event.pageX-35; f_l=x_middle-file_width/2; f_r=x_middle+file_width/2; x = f_l; if(f_lb_r) { x = b_r-file_width; } obj = document.getElementById(objName+"Div"); obj.style.top = y; obj.style.left = x; } else { obj = document.getElementById(objName+"Div"); obj.style.top=event.srcElement.offsetTop; obj.style.left =event.x-10;//-event.target.offsetLeft;*/ } } function fclick_upload2(event,objName) { bw = navigator.appName; if(bw=="Netscape") { obj = document.getElementById(objName+"Div"); file_width = 77; y = event.target.offsetTop-7; b_l =event.target.offsetLeft; b_r =event.target.offsetLeft+event.target.width; x_middle = event.pageX-276; f_l=x_middle-file_width/2; f_r=x_middle+file_width/2; x = f_l; if(f_lb_r) { x = b_r-file_width; } obj.style.top = y; obj.style.left = x; } else { obj = document.getElementById(objName+"Div"); obj.style.top=event.srcElement.offsetTop; obj.style.left =event.x-10;//-event.target.offsetLeft;*/ } } /* function getImageSize(warn_h,warn_w,imgObj) { ddx = document.getElementById("tmp_img"); ddx.src = imgObj.src; o=0; while(o<6000) { o++; } h=ddx.height; w=ddx.width; if(warn_h <= h || warn_w <= w) { i1= h/warn_h; i2= w/warn_w; i = Math.max(i1,i2); h=Math.round(h/i); w=Math.round(w/i); } else if(warn_h > h && warn_w > w) { i1= warn_h/h; i2= warn_w/w; i = Math.min(i1,i2); h=Math.round(h*i); w=Math.floor(w*i); } imgObj.style.height =h; imgObj.style.width =w; } */ function display_do(id,status) { obj = document.getElementById(id); obj.style.display=status; } function mb_strlen1(v) { return v.length; } function mb_substr1(s1,i,x) { return s1.substr(i,x); } function checkPassword1(v) { if(mb_strlen1(v)<8) { return false; } s1="1234567890"; s2="qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM"; ok1 =false; ok2 =false; for(i=0;i